diff --git a/.github/workflows/corpus.yml b/.github/workflows/corpus.yml index 7f55d1d9..e82229e8 100644 --- a/.github/workflows/corpus.yml +++ b/.github/workflows/corpus.yml @@ -3,14 +3,14 @@ on: workflow_dispatch: schedule: - cron: "0 0 * * *" - # push: jobs: - build: + Check-Upstream: defaults: run: shell: bash runs-on: ubuntu-latest + if: github.repository == 'cedar-policy/cedar-go' steps: - uses: actions/checkout@v4 @@ -20,19 +20,32 @@ jobs: # cmp returns status code 1 if the files differ - name: Compare + id: compare run: cmp /tmp/corpus-tests.tar.gz corpus-tests.tar.gz - name: Notify on Failure - if: failure() && github.event_name == 'schedule' - uses: actions/github-script@v6 + if: failure() && steps.compare.outcome == 'failure' + uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - github.rest.issues.create({ + // Get a list of all open issues called 'Upstream Integration Test Corpus Modified' + const issues = await github.paginate(github.rest.issues.listForRepo, { owner: context.repo.owner, repo: context.repo.repo, - title: 'Upstream Integration Test Corpus Modified', - body: 'The upstream integration test corpus at https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz has been updated. Please integrate the changes into the local copy.' - assignees: ['jmccarthy', 'philhassey', 'patjakdev'], - labels: ['bug'] + labels: 'upstream-corpus-test' }) + .then((issues) => { + console.log(`Found ${issues.length} open issues`) + // If one doesn't exist, create it + if (issues.length === 0) { + github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: 'Upstream Integration Test Corpus Modified', + body: 'The upstream integration test corpus at https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz has been updated. Please integrate the changes into the local copy.', + assignees: ['jmccarthy', 'philhassey', 'patjakdev'], + labels: ['upstream-corpus-test'] + }) + } + }); \ No newline at end of file