Upstream Tracking #324
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Upstream Tracking | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| schedule: | |
| - cron: "0 7 * * *" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| upstream: | |
| name: Upstream Tracking | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Find if any changes occured upstream | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const upstreamSources = require('./.github/upstream-sources.json') | |
| for (const source of upstreamSources) { | |
| Promise.all([ | |
| github.rest.repos.getContent({ | |
| owner: source.owner, | |
| repo: source.repo, | |
| path: source.path, | |
| ref: source.tag, | |
| }), | |
| github.rest.repos | |
| .getLatestRelease({ | |
| owner: source.owner, | |
| repo: source.repo, | |
| }) | |
| .then((tags) => { | |
| return github.rest.repos.getContent({ | |
| owner: source.owner, | |
| repo: source.repo, | |
| path: source.path, | |
| ref: tags.data.tag_name, | |
| }) | |
| }), | |
| ]).then(([current, latest]) => { | |
| if (current.data.sha != latest.data.sha) { | |
| core.setFailed(` | |
| <${current.data.html_url}> has been updated to <${latest.data.html_url}>. | |
| Check if the relevant code needs to be updated and then update the entry in \`.github/upstream-sources.json\`. | |
| `) | |
| } | |
| }) | |
| } |