github-activity-readme icon indicating copy to clipboard operation
github-activity-readme copied to clipboard

Add INJECT option to inject js at runtime (and some other stuff, I got carried away)

Open non-bin opened this issue 4 years ago • 1 comments

This makes it possible for people to, for example: extend the script to work with other event types, and filter events

non-bin avatar Aug 17 '21 05:08 non-bin

an example of js that I would like to inject is

// add serializer for releases
serializers.ReleaseEvent = (item) => {
  return `🏷️ Released [${item.payload.tag_name}](${urlPrefix}/${item.repo.name}/releases/${item.payload.tag_name}) of ${toUrlFormat(
    item.repo.name
  )}`;
}

// only show one event of each type
processEvents = (events) => {
  const output = []
  const usedTypes = []

  // Filter out any boring activity
  const filtered = events.filter((event) => serializers.hasOwnProperty(event.type))

  filtered.forEach(event => {
    if (!usedTypes.includes(event.type)) {
      usedTypes.push(event.type)
      output.push(serializers[item.type](item))
    }
  });
}

non-bin avatar Aug 17 '21 06:08 non-bin

Hi @non-bin seems like a cool idea and you seem to know what you are doing. Unfortunately, not everyone is this well versed with JavaScript. This feature would broaden the scope of the Action way to much and I see the risk of unintended malfunction and code injection. Which would most likely cause a lot of raised issues that are not truly related to this GitHub Action.

Therefore I unfortunately have to decline this PR to keep the scope in line and manageable.

tuunit avatar May 31 '23 05:05 tuunit

FYI: Release event will be added with #97

tuunit avatar May 31 '23 05:05 tuunit

Fair enough, I'll keep using it just thought someone might find it useful ☺️

non-bin avatar May 31 '23 05:05 non-bin