From adc5fb7fdf310e5b01d4003b8db338be2942331e Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 12:05:27 +0200 Subject: [PATCH 01/15] ci: Add some additional GH project automation --- .github/workflows/project-automation.yml | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/project-automation.yml diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml new file mode 100644 index 000000000000..4134eb879dfe --- /dev/null +++ b/.github/workflows/project-automation.yml @@ -0,0 +1,61 @@ +name: "Automation: Update GH Project" +on: + pull_request: + types: + - closed + - opened + - reopened + - ready_for_review + +jobs: + # When a PR is a draft, it should go into "In Progress" + mark_as_in_progress: + if: | + (github.event.action == 'opened' || github.event.action == 'reopened') + && github.event.pull_request.draft == true + runs-on: ubuntu-latest + steps: + - name: Update status to in_progress + id: update_status + uses: peter-evans/create-or-update-project-card@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + project-location: getsentry + project-number: 31 + column-name: "🏗 In Progress" + issue-number: ${{ github.event.number }} + + # When a PR is not a draft, it should go into "In Review" + mark_as_in_review: + if: | + (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review') + && github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - name: Update status to in_review + id: update_status + uses: peter-evans/create-or-update-project-card@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + project-location: getsentry + project-number: 31 + column-name: "👀 In Review" + issue-number: ${{ github.event.number }} + + + # By default, closed PRs go into "Ready for Release" + # But if they are closed without merging, they should go into "Done" + mark_as_done: + if: | + github.event.action == 'closed' && github.event.pull_request.merged == false + runs-on: ubuntu-latest + steps: + - name: Update status to done + id: update_status + uses: peter-evans/create-or-update-project-card@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + project-location: getsentry + project-number: 31 + column-name: "✅ Done" + issue-number: ${{ github.event.number }} From d20e027cb2998cf5c10c263da5d0b455e7b9ec77 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 12:12:04 +0200 Subject: [PATCH 02/15] update project location? --- .github/workflows/project-automation.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 4134eb879dfe..65b2ad7b68e2 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -20,7 +20,6 @@ jobs: uses: peter-evans/create-or-update-project-card@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - project-location: getsentry project-number: 31 column-name: "🏗 In Progress" issue-number: ${{ github.event.number }} @@ -37,7 +36,6 @@ jobs: uses: peter-evans/create-or-update-project-card@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - project-location: getsentry project-number: 31 column-name: "👀 In Review" issue-number: ${{ github.event.number }} @@ -55,7 +53,6 @@ jobs: uses: peter-evans/create-or-update-project-card@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - project-location: getsentry project-number: 31 column-name: "✅ Done" issue-number: ${{ github.event.number }} From 9fdafc57993ff02bd9887b080210827ebee784b1 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 12:13:09 +0200 Subject: [PATCH 03/15] Revert "update project location?" This reverts commit d20e027cb2998cf5c10c263da5d0b455e7b9ec77. --- .github/workflows/project-automation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 65b2ad7b68e2..4134eb879dfe 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -20,6 +20,7 @@ jobs: uses: peter-evans/create-or-update-project-card@v3 with: token: ${{ secrets.GITHUB_TOKEN }} + project-location: getsentry project-number: 31 column-name: "🏗 In Progress" issue-number: ${{ github.event.number }} @@ -36,6 +37,7 @@ jobs: uses: peter-evans/create-or-update-project-card@v3 with: token: ${{ secrets.GITHUB_TOKEN }} + project-location: getsentry project-number: 31 column-name: "👀 In Review" issue-number: ${{ github.event.number }} @@ -53,6 +55,7 @@ jobs: uses: peter-evans/create-or-update-project-card@v3 with: token: ${{ secrets.GITHUB_TOKEN }} + project-location: getsentry project-number: 31 column-name: "✅ Done" issue-number: ${{ github.event.number }} From ca722ba9d7f35707ce243b0adf42adc0547d820a Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 13:50:55 +0200 Subject: [PATCH 04/15] try other token --- .github/workflows/project-automation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 4134eb879dfe..605f9172a237 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -19,7 +19,7 @@ jobs: id: update_status uses: peter-evans/create-or-update-project-card@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GH_PROJECT_AUTOMATION }} project-location: getsentry project-number: 31 column-name: "🏗 In Progress" @@ -36,7 +36,7 @@ jobs: id: update_status uses: peter-evans/create-or-update-project-card@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GH_PROJECT_AUTOMATION }} project-location: getsentry project-number: 31 column-name: "👀 In Review" @@ -54,7 +54,7 @@ jobs: id: update_status uses: peter-evans/create-or-update-project-card@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GH_PROJECT_AUTOMATION }} project-location: getsentry project-number: 31 column-name: "✅ Done" From bcc5c2e4c42030b585db4c6f6548177e6578ee1f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 14:00:20 +0200 Subject: [PATCH 05/15] try other action --- .github/workflows/project-automation.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 605f9172a237..13cd2cf3ac97 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -34,14 +34,14 @@ jobs: steps: - name: Update status to in_review id: update_status - uses: peter-evans/create-or-update-project-card@v3 + uses: github/update-project-action@v3 with: - token: ${{ secrets.GH_PROJECT_AUTOMATION }} - project-location: getsentry - project-number: 31 - column-name: "👀 In Review" - issue-number: ${{ github.event.number }} - + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} + organization: getsentry + project_number: 31 + content_id: ${{ github.event.number }} + field: Status + value: "👀 In Review" # By default, closed PRs go into "Ready for Release" # But if they are closed without merging, they should go into "Done" From d5de4c9af8f5cf4bc5f45088d37a3895b2c549b8 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 14:02:52 +0200 Subject: [PATCH 06/15] use pr id? --- .github/workflows/project-automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 13cd2cf3ac97..4a88b29b296e 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -39,7 +39,7 @@ jobs: github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} organization: getsentry project_number: 31 - content_id: ${{ github.event.number }} + content_id: ${{ github.event.pull_request.id }} field: Status value: "👀 In Review" From 297b6fe543e64cb97ceea7bad3a41adce1c1f63f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 14:06:41 +0200 Subject: [PATCH 07/15] use node_id? --- .github/workflows/project-automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 4a88b29b296e..67f27ba28e4b 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -39,7 +39,7 @@ jobs: github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} organization: getsentry project_number: 31 - content_id: ${{ github.event.pull_request.id }} + content_id: ${{ github.event.pull_request.node_id }} field: Status value: "👀 In Review" From 7d06c494eeaa80c6050be302c2c7b10ac2ed06a0 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 6 Sep 2024 14:23:12 +0200 Subject: [PATCH 08/15] use other action --- .github/workflows/project-automation.yml | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 67f27ba28e4b..dddb8a548cc7 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -16,14 +16,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Update status to in_progress - id: update_status - uses: peter-evans/create-or-update-project-card@v3 + uses: github/update-project-action@v3 with: - token: ${{ secrets.GH_PROJECT_AUTOMATION }} - project-location: getsentry - project-number: 31 - column-name: "🏗 In Progress" - issue-number: ${{ github.event.number }} + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} + organization: getsentry + project_number: 31 + content_id: ${{ github.event.pull_request.node_id }} + field: Status + value: "🏗 In Progress" # When a PR is not a draft, it should go into "In Review" mark_as_in_review: @@ -52,10 +52,12 @@ jobs: steps: - name: Update status to done id: update_status - uses: peter-evans/create-or-update-project-card@v3 + uses: github/update-project-action@v3 with: - token: ${{ secrets.GH_PROJECT_AUTOMATION }} - project-location: getsentry - project-number: 31 - column-name: "✅ Done" - issue-number: ${{ github.event.number }} + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} + organization: getsentry + project_number: 31 + content_id: ${{ github.event.pull_request.node_id }} + field: Status + value: "✅ Done" + From a057d8fd5d4a62772434231316054a0bd7a72293 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 09:20:12 +0200 Subject: [PATCH 09/15] try main --- .github/workflows/project-automation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index dddb8a548cc7..7b1bc7d95f32 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Update status to in_progress - uses: github/update-project-action@v3 + uses: github/update-project-action@main with: github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} organization: getsentry @@ -34,7 +34,7 @@ jobs: steps: - name: Update status to in_review id: update_status - uses: github/update-project-action@v3 + uses: github/update-project-action@main with: github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} organization: getsentry @@ -52,7 +52,7 @@ jobs: steps: - name: Update status to done id: update_status - uses: github/update-project-action@v3 + uses: github/update-project-action@main with: github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} organization: getsentry From cd05e7bb50c4ceea336b1599a8560ce5e9a9405c Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 13:19:52 +0200 Subject: [PATCH 10/15] handle convert to draft --- .github/workflows/project-automation.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 7b1bc7d95f32..c2f95d57895d 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -6,12 +6,13 @@ on: - opened - reopened - ready_for_review + - converted_to_draft jobs: # When a PR is a draft, it should go into "In Progress" mark_as_in_progress: if: | - (github.event.action == 'opened' || github.event.action == 'reopened') + (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'converted_to_draft') && github.event.pull_request.draft == true runs-on: ubuntu-latest steps: From e2f04fdaac9ff8d2346304418f5345be1f8cb305 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 13:31:58 +0200 Subject: [PATCH 11/15] check for project --- .github/workflows/project-automation.yml | 38 ++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index c2f95d57895d..d96b5660f43d 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -9,10 +9,38 @@ on: - converted_to_draft jobs: + # Check if PR is in project + check_project: + runs-on: ubuntu-latest + steps: + - name: Check if PR is in project + id: check_project + uses: github/update-project-action@main + with: + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} + organization: getsentry + project_number: 31 + content_id: ${{ github.event.pull_request.node_id }} + field: Status + operation: read + + - name: PR is not in project + if: failure() + run: echo "is_in_project=0" >> "$GITHUB_OUTPUT" + + - name: PR is in project + if: success() + run: echo "is_in_project=1" >> "$GITHUB_OUTPUT" + + outputs: + is_in_project: '${{ steps.check_project.outputs.is_in_project }}' + # When a PR is a draft, it should go into "In Progress" mark_as_in_progress: + needs: check_project if: | - (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'converted_to_draft') + needs.check_project.outputs.is_in_project == '1' + && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'converted_to_draft') && github.event.pull_request.draft == true runs-on: ubuntu-latest steps: @@ -28,8 +56,10 @@ jobs: # When a PR is not a draft, it should go into "In Review" mark_as_in_review: + needs: check_project if: | - (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review') + needs.check_project.outputs.is_in_project == '1' + && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review') && github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -47,8 +77,10 @@ jobs: # By default, closed PRs go into "Ready for Release" # But if they are closed without merging, they should go into "Done" mark_as_done: + needs: check_project if: | - github.event.action == 'closed' && github.event.pull_request.merged == false + needs.check_project.outputs.is_in_project == '1' + && github.event.action == 'closed' && github.event.pull_request.merged == false runs-on: ubuntu-latest steps: - name: Update status to done From c53415f8ceacee7aba84feadbe3b15d8146e7885 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 13:35:22 +0200 Subject: [PATCH 12/15] continue on error --- .github/workflows/project-automation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index d96b5660f43d..1c738a659f45 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check if PR is in project + continue-on-error: true id: check_project uses: github/update-project-action@main with: From 42c0dd861fdcd50bddca63feddc8c5317c586527 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 13:38:33 +0200 Subject: [PATCH 13/15] fix check --- .github/workflows/project-automation.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 1c738a659f45..a1a1db996f89 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -25,16 +25,13 @@ jobs: field: Status operation: read - - name: PR is not in project - if: failure() - run: echo "is_in_project=0" >> "$GITHUB_OUTPUT" - - name: PR is in project - if: success() + if: steps.check_project.outputs.field_read_value + id: is_in_project run: echo "is_in_project=1" >> "$GITHUB_OUTPUT" outputs: - is_in_project: '${{ steps.check_project.outputs.is_in_project }}' + is_in_project: ${{ steps.is_in_project.outputs.is_in_project || '0' }} # When a PR is a draft, it should go into "In Progress" mark_as_in_progress: From 9b986c7c53d8871735acd7288d6dd0b31873e70d Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 13:41:00 +0200 Subject: [PATCH 14/15] better label --- .github/workflows/project-automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index a1a1db996f89..61c7eaaaaba4 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -25,7 +25,7 @@ jobs: field: Status operation: read - - name: PR is in project + - name: If project field is read, set is_in_project to 1 if: steps.check_project.outputs.field_read_value id: is_in_project run: echo "is_in_project=1" >> "$GITHUB_OUTPUT" From c779025870992eb1cb544e4021e71ea9a73c859c Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 9 Sep 2024 13:41:53 +0200 Subject: [PATCH 15/15] better names --- .github/workflows/project-automation.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml index 61c7eaaaaba4..6d82d8a2c923 100644 --- a/.github/workflows/project-automation.yml +++ b/.github/workflows/project-automation.yml @@ -11,6 +11,7 @@ on: jobs: # Check if PR is in project check_project: + name: Check if PR is in project runs-on: ubuntu-latest steps: - name: Check if PR is in project @@ -35,6 +36,7 @@ jobs: # When a PR is a draft, it should go into "In Progress" mark_as_in_progress: + name: "Mark as In Progress" needs: check_project if: | needs.check_project.outputs.is_in_project == '1' @@ -54,6 +56,7 @@ jobs: # When a PR is not a draft, it should go into "In Review" mark_as_in_review: + name: "Mark as In Review" needs: check_project if: | needs.check_project.outputs.is_in_project == '1' @@ -75,6 +78,7 @@ jobs: # By default, closed PRs go into "Ready for Release" # But if they are closed without merging, they should go into "Done" mark_as_done: + name: "Mark as Done" needs: check_project if: | needs.check_project.outputs.is_in_project == '1'