[Test] Add simple_dep_pkg
#5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-Merge Validated Packages | |
| on: | |
| pull_request_target: | |
| types: [labeled] | |
| branches: | |
| - packages | |
| paths: | |
| - '*/hatch_metadata.json' | |
| jobs: | |
| auto-merge: | |
| if: github.event.label.name == 'reviewed' && github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App token | |
| id: generate-token | |
| uses: tibdex/github-app-token@v2 | |
| with: | |
| app_id: ${{ secrets.HATCH_WORKFLOW_APP_ID }} | |
| private_key: ${{ secrets.HATCH_WORKFLOW_APP_PRIVATE_KEY }} | |
| - name: Check PR for conflicts | |
| id: check-conflicts | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.generate-token.outputs.token }} | |
| script: | | |
| const pr = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number | |
| }); | |
| if (pr.data.mergeable === false) { | |
| console.log('PR has conflicts that need to be resolved'); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: '⚠️ This PR has merge conflicts that need to be resolved before it can be auto-merged. Please resolve the conflicts and try again.' | |
| }); | |
| return core.setFailed('PR has merge conflicts'); | |
| } | |
| console.log('PR is ready to be merged'); | |
| // Add the label "automerge" to the PR | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| labels: ['automerge'] | |
| }); | |
| ); | |
| - name: Notify PR author | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.generate-token.outputs.token }} | |
| script: | | |
| const pr_number = "${{ github.event.pull_request.number }}" | |
| const message = `All validation passed, the review is complete, and no conflicts were detected.\nThis PR will be auto-merged.` | |
| await github.rest.issues.createComment({ | |
| issue_number: pr_number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: message | |
| }) | |
| - name: Auto-approve PR | |
| if: success() | |
| uses: hmarr/auto-approve-action@v4 | |
| with: | |
| github-token: ${{ steps.generate-token.outputs.token }} | |
| - name: Auto-merge PR | |
| if: success() | |
| uses: pascalgn/automerge-action@v0.16.4 | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| MERGE_METHOD: merge # Same as the default, but explicit | |
| MERGE_LABELS: "reviewed,validation-passed,automerge" # Labels that trigger the merge | |
| MERGE_REMOVE_LABELS: "ready-for-review,validation-passed,automerge" # Labels to remove after merging | |
| MERGE_FORKS: true # Same as the default, but explicit |