Automatizing GitHub workflow that involves 3rd party repo

Viewed 22

I have a GitHub repo myRepo that scans the contents of another repo theirRepo and converts them to JSON files. The details aren't really that important, just so much that myRepo uses nodeJS and holds theirRepo as a submodule. Licensewise this is not a problem.

What I'd like to achieve is that, when theirRepo merges into main, myRepo magically updates and builds the new files. I'd like to use existing infrastructures such as GitHub actions, Netlify build processes etc.

How would you approach this?

I don't expect a detailed solution for the magical part, but am rather looking for a few pointers, something that gets me started.

1 Answers

As GitHub Actions (AFAIK) does not currently allow to trigger events based on changes in other repositories (unless you control another repository’s workflows) one might have to hack a little bit.

File change in OtherRepo

I’m not familiar with Node, but, depending on the project culture following files might change during the new release/main branch update:

  • package-lock.json
  • CHANGELOG.md (for semantic versioning)

This is a rough approximation, you might also want to identify multiple files likely to change with each merged PR.

Cron based jobs

Run your job every N hours/minutes or another time interval to check for changes.

Use caching

Run your action only when files in another repo change, something along these lines:

steps:
  - run: curl <path to file> -o output1
  - run: curl <path to file2> -o output2
  - name: Cache
    uses: actions/cache@v3
    id: cache
    with:
      key: ${{ hashFiles(”output1”, “output2”) }}
  - name: Update repo
    if: steps.cache.output.cache-hit != “true”
    run: <do your stuff>
Related