From e3c2ab54c9a0e9d4e9541c5ab106dbaaf0bacbe8 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:08:07 -0800 Subject: [PATCH 1/6] update associated issue check --- .github/workflows/pr-file-check.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 4e32915955ea..dc64e9913343 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -14,6 +14,18 @@ jobs: name: 'Check for changed files' runs-on: ubuntu-latest steps: + - name: 'Add "issue-please" label' + if: github.event.action == 'opened' + uses: actions/github-script@v6 + with: + script: | + github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['issue-please'] + }) + - name: 'package-lock.json matches package.json' uses: brettcannon/check-for-changed-files@v1.2.1 with: @@ -46,6 +58,9 @@ jobs: with: script: | const labels = context.payload.pull_request.labels.map(label => label.name); + if (labels.includes('issue-please')) { + core.setFailed('The "issue-please" label is present. Please associate an issue and remove the label.'); + } if (!labels.includes('skip-issue-check')) { const issueLink = context.payload.pull_request.body.match(/https:\/\/github\.com\/\S+\/issues\/\d+/); if (!issueLink) { From 30e9739d8bc7f80f8b41e4e2f9aec7152ee6a18a Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:10:29 -0800 Subject: [PATCH 2/6] update method --- .github/workflows/pr-file-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index dc64e9913343..09c4a22ac283 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -19,7 +19,7 @@ jobs: uses: actions/github-script@v6 with: script: | - github.issues.addLabels({ + github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, From 4a8c6dd615b76ed997e0448786055a3d12d626d8 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:15:25 -0800 Subject: [PATCH 3/6] update how to add label --- .github/workflows/pr-file-check.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 09c4a22ac283..923217673c30 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -14,18 +14,6 @@ jobs: name: 'Check for changed files' runs-on: ubuntu-latest steps: - - name: 'Add "issue-please" label' - if: github.event.action == 'opened' - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: ['issue-please'] - }) - - name: 'package-lock.json matches package.json' uses: brettcannon/check-for-changed-files@v1.2.1 with: @@ -53,6 +41,11 @@ jobs: skip-label: 'skip tests' failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)' + - name: Add "issue-please" Label + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'issue-please' - name: 'Ensure PR has an associated issue' uses: actions/github-script@v6 with: From 5c71846f8acbd2b0e446e5f404fbc93461845af0 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:29:11 -0800 Subject: [PATCH 4/6] write permissions --- .github/workflows/pr-file-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 923217673c30..993ed429b204 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -9,6 +9,9 @@ on: - 'labeled' - 'unlabeled' +permissions: + issues: write + jobs: changed-files-in-pr: name: 'Check for changed files' From ac585c87b059ba836a6425471d8dd40892e921c4 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:34:31 -0800 Subject: [PATCH 5/6] write privilege --- .github/workflows/pr-file-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 993ed429b204..64b434408446 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -10,7 +10,7 @@ on: - 'unlabeled' permissions: - issues: write + pull-requests: write jobs: changed-files-in-pr: From c09dc734fd224d3ea285f95c4479ff69066562b2 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:35:39 -0800 Subject: [PATCH 6/6] take 3 --- .github/workflows/pr-file-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 64b434408446..ad2585e6ffea 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -10,6 +10,7 @@ on: - 'unlabeled' permissions: + contents: read pull-requests: write jobs: