|
| 1 | +name: "Automation: Update GH Project" |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: |
| 5 | + - closed |
| 6 | + - opened |
| 7 | + - reopened |
| 8 | + - ready_for_review |
| 9 | + - converted_to_draft |
| 10 | + |
| 11 | +jobs: |
| 12 | + # Check if PR is in project |
| 13 | + check_project: |
| 14 | + name: Check if PR is in project |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Check if PR is in project |
| 18 | + continue-on-error: true |
| 19 | + id: check_project |
| 20 | + uses: github/update-project-action@f980378bc179626af5b4e20ec05ec39c7f7a6f6d |
| 21 | + with: |
| 22 | + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} |
| 23 | + organization: getsentry |
| 24 | + project_number: 31 |
| 25 | + content_id: ${{ github.event.pull_request.node_id }} |
| 26 | + field: Status |
| 27 | + operation: read |
| 28 | + |
| 29 | + - name: If project field is read, set is_in_project to 1 |
| 30 | + if: steps.check_project.outputs.field_read_value |
| 31 | + id: is_in_project |
| 32 | + run: echo "is_in_project=1" >> "$GITHUB_OUTPUT" |
| 33 | + |
| 34 | + outputs: |
| 35 | + is_in_project: ${{ steps.is_in_project.outputs.is_in_project || '0' }} |
| 36 | + |
| 37 | + # When a PR is a draft, it should go into "In Progress" |
| 38 | + mark_as_in_progress: |
| 39 | + name: "Mark as In Progress" |
| 40 | + needs: check_project |
| 41 | + if: | |
| 42 | + needs.check_project.outputs.is_in_project == '1' |
| 43 | + && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'converted_to_draft') |
| 44 | + && github.event.pull_request.draft == true |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - name: Update status to in_progress |
| 48 | + uses: github/update-project-action@f980378bc179626af5b4e20ec05ec39c7f7a6f6d |
| 49 | + with: |
| 50 | + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} |
| 51 | + organization: getsentry |
| 52 | + project_number: 31 |
| 53 | + content_id: ${{ github.event.pull_request.node_id }} |
| 54 | + field: Status |
| 55 | + value: "🏗 In Progress" |
| 56 | + |
| 57 | + # When a PR is not a draft, it should go into "In Review" |
| 58 | + mark_as_in_review: |
| 59 | + name: "Mark as In Review" |
| 60 | + needs: check_project |
| 61 | + if: | |
| 62 | + needs.check_project.outputs.is_in_project == '1' |
| 63 | + && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review') |
| 64 | + && github.event.pull_request.draft == false |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Update status to in_review |
| 68 | + id: update_status |
| 69 | + uses: github/update-project-action@f980378bc179626af5b4e20ec05ec39c7f7a6f6d |
| 70 | + with: |
| 71 | + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} |
| 72 | + organization: getsentry |
| 73 | + project_number: 31 |
| 74 | + content_id: ${{ github.event.pull_request.node_id }} |
| 75 | + field: Status |
| 76 | + value: "👀 In Review" |
| 77 | + |
| 78 | + # By default, closed PRs go into "Ready for Release" |
| 79 | + # But if they are closed without merging, they should go into "Done" |
| 80 | + mark_as_done: |
| 81 | + name: "Mark as Done" |
| 82 | + needs: check_project |
| 83 | + if: | |
| 84 | + needs.check_project.outputs.is_in_project == '1' |
| 85 | + && github.event.action == 'closed' && github.event.pull_request.merged == false |
| 86 | + runs-on: ubuntu-latest |
| 87 | + steps: |
| 88 | + - name: Update status to done |
| 89 | + id: update_status |
| 90 | + uses: github/update-project-action@f980378bc179626af5b4e20ec05ec39c7f7a6f6d |
| 91 | + with: |
| 92 | + github_token: ${{ secrets.GH_PROJECT_AUTOMATION }} |
| 93 | + organization: getsentry |
| 94 | + project_number: 31 |
| 95 | + content_id: ${{ github.event.pull_request.node_id }} |
| 96 | + field: Status |
| 97 | + value: "✅ Done" |
| 98 | + |
0 commit comments