Home > OS >  Is it possible to run GitHub action when a repo I fork releases a new release?
Is it possible to run GitHub action when a repo I fork releases a new release?

Time:06-20

Is it possible to run GitHub action on a fork, whenever the original forked project publishes a new release ?

CodePudding user response:

You can use the [release] event but note that more than one activity can trigger it.

on:
  release:
    types: [published]

For the details of each event check the Webhook events, the one you need is [published] and repository key which is the repository where the event occurs.

CodePudding user response:

As of Jun 2022, there is no trigger that runs the workflow when the upstream (the repo you forked) does something.

So what you'll have to do is create a workflow that runs on schedule, pull the upstream repository and check if there is something new.

If you just want to copy commits 1:1, then you could use the action aormsby/Fork-Sync-With-Upstream-action: https://github.com/aormsby/Fork-Sync-With-Upstream-action

If tags are good enough, you could take inspiration from the above action and compare the tags in your repository with the ones from upstream.

If you really need releases (GitHub Releases), then you're probably going to have to maintain some custom state somewhere to remember which releases you have already seen. Or alternatively, replicate all upstream releases in your repository. This would allow you to create a separate workflow that triggers on release, like so:

  1. Pull upstream repository
  2. Recreate all upstream releases in your repository (unless they exist already)
  3. Trigger a separate workflow on: release
  • Related