|
5 | 5 | types: [release-package] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - # Auto-merge if validation passed |
9 | | - auto-merge-if-validation-passed: |
| 8 | + # 1. Auto-merge if validation passed |
| 9 | + check-conflicts-in-merge: |
10 | 10 | runs-on: ubuntu-latest |
11 | 11 | steps: |
12 | 12 | - name: Checkout repository |
@@ -57,56 +57,10 @@ jobs: |
57 | 57 | }); |
58 | 58 | |
59 | 59 | return { can_merge: true }; |
60 | | - |
61 | | - - name: Notify PR author of success |
62 | | - uses: actions/github-script@v7 |
63 | | - with: |
64 | | - github-token: ${{ steps.generate-token.outputs.token }} |
65 | | - script: | |
66 | | - const message = [ |
67 | | - "### ✅ No conflicts detected.", |
68 | | - "", |
69 | | - "This PR will be auto-approved and auto-merged shortly.", |
70 | | - "", |
71 | | - "### Next Steps", |
72 | | - "", |
73 | | - "1. The package will be released to the registry under the lowest trust level: unreviewed.", |
74 | | - "2. The package will be available for download from the Hatch! package manager.", |
75 | | - "3. A review issue will be created in the [repository](https://github.com/${{ github.repository }}/issues) for this package.", |
76 | | - " - Package authors are encouraged to check the review issue and respond to any questions or concerns raised by the reviewers.", |
77 | | - "4. Once the review is complete, the package's trust level will be raised to: reviewed.", |
78 | | -
|
79 | | - ].join('\n'); |
80 | 60 |
|
81 | | - const prNumber = ${{ github.event.client_payload.pr_number }}; |
82 | | - const [owner, repo] = '${{ github.repository }}'.split('/'); |
83 | | - |
84 | | - await github.rest.issues.createComment({ |
85 | | - issue_number: prNumber, |
86 | | - owner: owner, |
87 | | - repo: repo, |
88 | | - body: message |
89 | | - }) |
90 | | -
|
91 | | - - name: Auto-approve PR |
92 | | - uses: hmarr/auto-approve-action@v4 |
93 | | - with: |
94 | | - github-token: ${{ steps.generate-token.outputs.token }} |
95 | | - pull-request-number: ${{ github.event.client_payload.pr_number }} |
96 | | - |
97 | | - - name: Auto-merge PR |
98 | | - uses: pascalgn/automerge-action@v0.16.4 |
99 | | - env: |
100 | | - GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
101 | | - MERGE_METHOD: merge |
102 | | - MERGE_LABELS: "validation-passed,automerge" |
103 | | - MERGE_REMOVE_LABELS: "validation-passed,automerge" |
104 | | - MERGE_FORKS: true |
105 | | - PULL_REQUEST: ${{ github.event.client_payload.pr_number }} |
106 | | - |
107 | | - # 3. Create Release and Review Issue |
| 61 | + # 2. Create Release and Review Issue |
108 | 62 | create-release-and-review: |
109 | | - needs: [auto-merge-if-validation-passed] |
| 63 | + needs: [check-conflicts-in-merge] |
110 | 64 | runs-on: ubuntu-latest |
111 | 65 | steps: |
112 | 66 | - name: Checkout repository |
@@ -146,16 +100,15 @@ jobs: |
146 | 100 | cd downloaded-package |
147 | 101 | zip -r ../${{ steps.package-info.outputs.release_name }}.zip . |
148 | 102 |
|
149 | | - # Create GitHub Release |
150 | 103 | - name: Create GitHub Release |
151 | 104 | id: create-release |
152 | 105 | uses: softprops/action-gh-release@v1 |
153 | 106 | with: |
154 | 107 | files: ${{ steps.package-info.outputs.release_name }}.zip |
155 | 108 | name: ${{ steps.package-info.outputs.release_name }} |
| 109 | + tag_name: ${{ steps.package-info.outputs.release_name }} |
156 | 110 | token: ${{ steps.generate-token.outputs.token }} |
157 | 111 |
|
158 | | - # Retrieve PR author information |
159 | 112 | - name: Retrieve PR author information |
160 | 113 | id: author-info |
161 | 114 | uses: actions/github-script@v7 |
@@ -231,3 +184,65 @@ jobs: |
231 | 184 | `, |
232 | 185 | labels: ['ready-for-review', 'package'] |
233 | 186 | }); |
| 187 | + |
| 188 | + # 3. Auto-approve and merge PR if validation, release, and review issue creation were successful |
| 189 | + approve-and-merge: |
| 190 | + runs-on: ubuntu-latest |
| 191 | + needs: [check-conflicts-in-merge, create-release-and-review] |
| 192 | + steps: |
| 193 | + - name: Checkout repository |
| 194 | + uses: actions/checkout@v4 |
| 195 | + |
| 196 | + - name: Generate GitHub App token |
| 197 | + id: generate-token |
| 198 | + uses: tibdex/github-app-token@v2 |
| 199 | + with: |
| 200 | + app_id: ${{ secrets.HATCH_WORKFLOW_APP_ID }} |
| 201 | + private_key: ${{ secrets.HATCH_WORKFLOW_APP_PRIVATE_KEY }} |
| 202 | + |
| 203 | + - name: Notify PR author of success |
| 204 | + uses: actions/github-script@v7 |
| 205 | + with: |
| 206 | + github-token: ${{ steps.generate-token.outputs.token }} |
| 207 | + script: | |
| 208 | + const message = [ |
| 209 | + "### ✅ No conflicts detected.", |
| 210 | + "", |
| 211 | + "The package has been successfully validated and [released](https://github.com/${{ github.repository }}/releases", |
| 212 | + "This PR will be auto-approved and auto-merged shortly.", |
| 213 | + "", |
| 214 | + "### Next Steps", |
| 215 | + "", |
| 216 | + "1. The package will be released to the registry under the lowest trust level: unreviewed.", |
| 217 | + "2. The package will be available for download from the Hatch! package manager.", |
| 218 | + "3. A review issue will be created in the [repository](https://github.com/${{ github.repository }}/issues) for this package.", |
| 219 | + " - Package authors are encouraged to check the review issue and respond to any questions or concerns raised by the reviewers.", |
| 220 | + "4. Once the review is complete, the package's trust level will be raised to: reviewed.", |
| 221 | +
|
| 222 | + ].join('\n'); |
| 223 | +
|
| 224 | + const prNumber = ${{ github.event.client_payload.pr_number }}; |
| 225 | + const [owner, repo] = '${{ github.repository }}'.split('/'); |
| 226 | + |
| 227 | + await github.rest.issues.createComment({ |
| 228 | + issue_number: prNumber, |
| 229 | + owner: owner, |
| 230 | + repo: repo, |
| 231 | + body: message |
| 232 | + }) |
| 233 | +
|
| 234 | + - name: Approve and merge PR |
| 235 | + uses: hmarr/auto-approve-action@v4 |
| 236 | + with: |
| 237 | + github-token: ${{ steps.generate-token.outputs.token }} |
| 238 | + pull-request-number: ${{ github.event.client_payload.pr_number }} |
| 239 | + |
| 240 | + - name: Auto-merge PR |
| 241 | + uses: pascalgn/automerge-action@v0.16.4 |
| 242 | + env: |
| 243 | + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
| 244 | + MERGE_METHOD: merge |
| 245 | + MERGE_LABELS: "validation-passed,automerge" |
| 246 | + MERGE_REMOVE_LABELS: "validation-passed,automerge" |
| 247 | + MERGE_FORKS: true |
| 248 | + PULL_REQUEST: ${{ github.event.client_payload.pr_number }} |
0 commit comments