From a1bcfa1e639293006d564c50a9eb0debd9eb34ee Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 21:27:45 -0400 Subject: [PATCH 01/10] use token for gh cli --- .github/workflows/verify-pull-request.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index 49ff7395..82e1d31e 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -19,6 +19,8 @@ jobs: new_body="Closes #$issue_number" >> $body gh pr edit -b $new_body echo "Edited the body to include the issue number $issue_number" + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: find-linked-issues uses: Ismoh-Games/find-linked-issues@v1.0.6 with: @@ -42,23 +44,30 @@ jobs: first_issue=gh issue view ${{ steps.find-linked-issues.outputs.linked-issues[1] }} --json assignees --jq ' .assignees' echo "first_assignee=$(fromJson(first_issue)[1].login" >> "$GITHUB_OUTPUT" - + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Set PR assignee run: | gh pr edit ${{ github.event.pull_request.number }} \ --add-assignee ${{ steps.get-issue-assignee.outputs.first_assignee }} + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Set PR reviewer to Declan if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'varunsingh87' }} run: | gh pr edit ${{ github.event.pull_request.number }} \ --add-reviewer "Datoneguy246" + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Set PR reviewer to Varun if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'Datoneguy246' }} run: | gh pr edit ${{ github.event.pull_request.number }} \ --add-reviewer "varunsingh87" + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Announce Success if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'True' }} From 67b9e048d3a8af99c53f39f92f93e2af3407be54 Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 21:40:09 -0400 Subject: [PATCH 02/10] use GH_TOKEN --- .github/workflows/verify-pull-request.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index 8a6c2d61..d3705687 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -23,7 +23,7 @@ jobs: gh pr edit -b $new_body echo "Edited the body to include the issue number $issue_number" env: - token: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: find-linked-issues uses: Ismoh-Games/find-linked-issues@v1.0.6 with: @@ -48,13 +48,13 @@ jobs: .assignees' echo "first_assignee=$(fromJson(first_issue)[1].login" >> "$GITHUB_OUTPUT" env: - token: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set PR assignee run: | gh pr edit ${{ github.event.pull_request.number }} \ --add-assignee ${{ steps.get-issue-assignee.outputs.first_assignee }} env: - token: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set PR reviewer to Declan if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'varunsingh87' }} @@ -62,7 +62,7 @@ jobs: gh pr edit ${{ github.event.pull_request.number }} \ --add-reviewer "Datoneguy246" with: - token: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set PR reviewer to Varun if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'Datoneguy246' }} @@ -70,7 +70,7 @@ jobs: gh pr edit ${{ github.event.pull_request.number }} \ --add-reviewer "varunsingh87" env: - token: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Announce Success if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'True' }} From a358b3896d93cc10baa03a2b31ab8db60da80395 Mon Sep 17 00:00:00 2001 From: Varun Singh <31084854+varunsingh87@users.noreply.github.com> Date: Mon, 28 Jul 2025 21:46:23 -0400 Subject: [PATCH 03/10] Update verify-pull-request.yml --- .github/workflows/verify-pull-request.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index d3705687..77b38f07 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -11,9 +11,6 @@ jobs: issues: read pull-requests: write steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: add-issue-to-body run: | # get the title, take the first word which should be the issue number, and add this to the body title=$(gh pr view ${{ github.event.pull_request.number }} --json title --jq '.title') From 3df02f72a05bc2a1c68883154e138db4b22eee65 Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 21:49:54 -0400 Subject: [PATCH 04/10] fix with --- .github/workflows/verify-pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index 77b38f07..6f66629c 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -58,7 +58,7 @@ jobs: run: | gh pr edit ${{ github.event.pull_request.number }} \ --add-reviewer "Datoneguy246" - with: + env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set PR reviewer to Varun From 6dfa2bce2a34a98a8d13ae857405b123b2c02b5b Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 22:01:11 -0400 Subject: [PATCH 05/10] read content --- .github/workflows/verify-pull-request.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index 6f66629c..eae1857a 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -8,9 +8,15 @@ jobs: mirror-linked-issue: runs-on: ubuntu-latest # find-linked-issue GitHub Action is only supported on Linux permissions: + content: read issues: read pull-requests: write steps: + - name: Checkout repository + uses: actions/checkout@v4 + sparse-checkout: | + .github + - name: add-issue-to-body run: | # get the title, take the first word which should be the issue number, and add this to the body title=$(gh pr view ${{ github.event.pull_request.number }} --json title --jq '.title') From 5e2fc34ea093415517ce64c44ad42e1d7f55df1b Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 22:02:25 -0400 Subject: [PATCH 06/10] contents --- .github/workflows/verify-pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index eae1857a..dda266cf 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -8,7 +8,7 @@ jobs: mirror-linked-issue: runs-on: ubuntu-latest # find-linked-issue GitHub Action is only supported on Linux permissions: - content: read + contents: read issues: read pull-requests: write steps: From 0c7257fae3fbeb03709b6719d5efbf669d9c9923 Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 22:03:29 -0400 Subject: [PATCH 07/10] with --- .github/workflows/verify-pull-request.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index dda266cf..ad554994 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -14,8 +14,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - sparse-checkout: | - .github + with: + sparse-checkout: | + .github - name: add-issue-to-body run: | # get the title, take the first word which should be the issue number, and add this to the body From 78912d1601b65b58e044a3e1bb5b1b18f18a190b Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Mon, 28 Jul 2025 22:05:10 -0400 Subject: [PATCH 08/10] pull_request --- .github/workflows/verify-pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index ad554994..e5a0dcbc 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -1,6 +1,6 @@ name: Verify Pull Request meets Requirements on: - pull_request_target: # need write permission + pull_request: # need write permission branches: - main types: [opened, edited] From 7a012312d91ec114101d0a163057da3352aac4e9 Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Tue, 29 Jul 2025 21:07:48 -0400 Subject: [PATCH 09/10] Use correct BASH syntax for verify-pull-request workflow --- .github/workflows/verify-pull-request.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index e5a0dcbc..af1b117e 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -17,18 +17,20 @@ jobs: with: sparse-checkout: | .github + token: ${{ secrets.GITHUB_TOKEN }} - name: add-issue-to-body run: | # get the title, take the first word which should be the issue number, and add this to the body title=$(gh pr view ${{ github.event.pull_request.number }} --json title --jq '.title') - issue_number=$title[(ws: :)1] + issue_number=${title% *} body=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq '.body') - new_body="Closes #$issue_number" >> $body - gh pr edit -b $new_body + echo new_body="Closes #$issue_number"$'\n\n'"$body + gh pr edit ${{ github.event.pull_request.number }} --body "$new_body" echo "Edited the body to include the issue number $issue_number" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: find-linked-issues + - id: find-linked-issues + name: Find Linked Issues uses: Ismoh-Games/find-linked-issues@v1.0.6 with: token: ${{ secrets.GITHUB_TOKEN }} From 68c7c0cbd2f609b0cb97431a1ab0296776150354 Mon Sep 17 00:00:00 2001 From: Varun Singh <31084854+varunsingh87@users.noreply.github.com> Date: Thu, 31 Jul 2025 21:42:37 -0400 Subject: [PATCH 10/10] 2 Make the verify pull request workflow (#1) * Remove checkout * Add missing quote * n * Use new-body * use variable * Use ody * Use '' * sss * Use a different action * Fix get-issue-assignee * Fix syntax error * use parameter expansion correctly * fix syntax again * a * simplify simplify simplify --- .github/workflows/verify-pull-request.yml | 64 +++++++---------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/.github/workflows/verify-pull-request.yml b/.github/workflows/verify-pull-request.yml index af1b117e..9efd718f 100644 --- a/.github/workflows/verify-pull-request.yml +++ b/.github/workflows/verify-pull-request.yml @@ -18,73 +18,47 @@ jobs: sparse-checkout: | .github token: ${{ secrets.GITHUB_TOKEN }} - - - name: add-issue-to-body + - id: add-issue-to-body + name: Link issue in body run: | # get the title, take the first word which should be the issue number, and add this to the body - title=$(gh pr view ${{ github.event.pull_request.number }} --json title --jq '.title') - issue_number=${title% *} - body=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq '.body') - echo new_body="Closes #$issue_number"$'\n\n'"$body + title="${{ github.event.pull_request.title }}" + issue_number=${title%% *} + new_body="Closes #$issue_number"$'\n\n'"${{ github.event.pull_request.body }}" gh pr edit ${{ github.event.pull_request.number }} --body "$new_body" echo "Edited the body to include the issue number $issue_number" + echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - id: find-linked-issues - name: Find Linked Issues - uses: Ismoh-Games/find-linked-issues@v1.0.6 + - id: copy-issue-labels + name: Copy Issue Labels + uses: michalvankodev/copy-issue-labels@v1.2.1 with: - token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ github.repository }} - pull-request-number: ${{ github.event.pull_request.number }} - pull-request-body: ${{ github.event.pull_request.body }} - copy-issues-labels: true - include-closed-issues: false - - # Use the output from the `find-linked-issues` step - - name: Use the output - run: | - echo "is-pull-request-linked-to-issues: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues }}" - echo "linked-issues: ${{ steps.find-linked-issues.outputs.linked-issues }}" - echo "pull-request-labels: ${{ steps.find-linked-issues.outputs.pull-request-labels }}" + repo-token: ${{ secrets.GITHUB_TOKEN }} + from-title: true - name: Get issue assignee id: get-issue-assignee run: | - first_issue=gh issue view ${{ steps.find-linked-issues.outputs.linked-issues[1] }} --json assignees --jq ' - .assignees' - echo "first_assignee=$(fromJson(first_issue)[1].login" >> "$GITHUB_OUTPUT" + first_assignee=$(gh issue view "${{ steps.add-issue-to-body.outputs.issue_number }}" \ + --json assignees \ + --jq '.assignees[0].login') + echo "first_assignee=$first_assignee" >> "$GITHUB_OUTPUT" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set PR assignee - run: | - gh pr edit ${{ github.event.pull_request.number }} \ - --add-assignee ${{ steps.get-issue-assignee.outputs.first_assignee }} + run: gh pr edit ${{ github.event.pull_request.number }} --add-assignee "${{ env.ISSUE_ASSIGNEE }}" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_ASSIGNEE: ${{ steps.get-issue-assignee.outputs.first_assignee }} - name: Set PR reviewer to Declan if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'varunsingh87' }} - run: | - gh pr edit ${{ github.event.pull_request.number }} \ - --add-reviewer "Datoneguy246" + run: gh pr edit ${{ github.event.pull_request.number }} --add-reviewer "Datoneguy246" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set PR reviewer to Varun if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'Datoneguy246' }} - run: | - gh pr edit ${{ github.event.pull_request.number }} \ - --add-reviewer "varunsingh87" + run: gh pr edit ${{ github.event.pull_request.number }} --add-reviewer "varunsingh87" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Announce Success - if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'True' }} - run: | - echo "Pull request is linked to issues" - - - name: Announce Failure - if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'False' }} - run: | - echo "::warning Pull request must have a linked issue before merging" - exit 1