From 10a35432ddf37ce85b44b04e875f26ce82988b8d Mon Sep 17 00:00:00 2001 From: Patrick Jakubowski Date: Mon, 9 Sep 2024 17:14:48 -0700 Subject: [PATCH] Update upstream corpus test modification workflow to open an issue only if one doesn't already exist --- .github/workflows/corpus.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/corpus.yml b/.github/workflows/corpus.yml index 7f55d1d9..86c49f36 100644 --- a/.github/workflows/corpus.yml +++ b/.github/workflows/corpus.yml @@ -6,7 +6,7 @@ on: # push: jobs: - build: + Check-Upstream: defaults: run: shell: bash @@ -23,16 +23,28 @@ jobs: 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() && github.event_name == 'schedule' + 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'] + title: 'Upstream Integration Test Corpus Modified' }) + .then((issues) => { + console.log(`Found ${issues.length} open issues: ${issues[0].title}`) + // 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: ['bug'] + }) + } + }); \ No newline at end of file