Watching our OSS repositories stars flying!

Following the video introduction tutorial, I loved the idea to know who stars our OSS repositories, and especially who unstars, so I can follow-up and figure out why!

This workflow is very similar to the tutorial, with a slightly better Slack message.

Potential improvements:

  • Ideally, I’d prefer to watch over all public repositories automatically instead of adding them one by one. But I don’t know if that’s possible.
  • Display the country the user is from, because that’s nice to know people from all over the world use your work! But this information isn’t part of the payload and it feels like I’d need to make another call before sending the Slack message.

Workflow:

Summary
{
  "name": "Watch GitHub OSS stars",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        980,
        160
      ]
    },
    {
      "parameters": {
        "owner": "UnlyEd",
        "repository": "next-right-now",
        "events": [
          "star"
        ]
      },
      "name": "Github Trigger",
      "type": "n8n-nodes-base.githubTrigger",
      "typeVersion": 1,
      "position": [
        770,
        100
      ],
      "webhookId": "7ec26c00-f410-49e2-ae52-a788c71b0829",
      "credentials": {
        "githubApi": "Vadorequest"
      }
    },
    {
      "parameters": {
        "channel": "oss-github-stars",
        "attachments": [
          {
            "title_link": "={{$json[\"body\"][\"repository\"][\"html_url\"]}}",
            "title": "={{$json[\"body\"][\"repository\"][\"full_name\"]}}",
            "color": "#48F20A",
            "image_url": "={{$json[\"body\"][\"sender\"][\"avatar_url\"]}}",
            "text": "=Got star from <{{$json[\"body\"][\"sender\"][\"html_url\"]}}|{{$json[\"body\"][\"sender\"][\"login\"]}}> ({{$json[\"body\"][\"repository\"][\"stargazers_count\"] -1}} > {{$json[\"body\"][\"repository\"][\"stargazers_count\"]}})"
          }
        ],
        "otherOptions": {}
      },
      "name": "Slack2",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        1200,
        320
      ],
      "retryOnFail": false,
      "notesInFlow": true,
      "credentials": {
        "slackApi": "Unly"
      },
      "color": "#48F20A",
      "notes": "Got star"
    }
  ],
  "connections": {
    "Github Trigger": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Slack2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "id": "1"
}
6 Likes

I added my workflow file (removed all the duplicated “GitHub Trigger” nodes to only keep one), in case other people would like to do something similar. :slight_smile:

Wow @Ambroise this is awesome! I will be borrowing this example when explaining multiple trigger possibilities to new users :slight_smile:

Regarding the potential improvements, you should be able to replace the Github triggers with one Webhook trigger. Github has a “Webhooks” feature where you can setup a webhook event and paste in your url (this would be the Webhook triggers’ URL):

This way, you simply copy the webhook trigger node URL and setup an event in each GitHub repo. If you find some time to try it, would love to know how this approach works out for you!

1 Like

I see! But I won’t go down that way because it doesn’t really help in this case, I think it’s much more work than doing what I did above, especially if the webhook changes, which shouldn’t happen, unless you delete the workflow and import it back.

Also, I prefer to centralize them all, it’s much easier that way.
But could come in handy for other use cases!

2 Likes

Thanks for sharing :heart:

1 Like