Repository navigation
GEN-2036 Improve the job list #86
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 | |
| on: | |
| pull_request_target: | |
| branches: | |
| - main | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| jobs: | |
| enable: | |
| name: Enable auto-merge | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| # This workflow intentionally does not check out or execute PR code. | |
| - name: Check whether the author has write access | |
| id: author-permission | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| run: | | |
| can_push=$(gh api \ | |
| "repos/$GITHUB_REPOSITORY/collaborators/$PR_AUTHOR/permission" \ | |
| --jq '.user.permissions.push') | |
| echo "can-push=$can_push" >> "$GITHUB_OUTPUT" | |
| if [ "$can_push" != "true" ]; then | |
| echo "Skipping pull request: $PR_AUTHOR does not have write access." | |
| fi | |
| - name: Merge after required checks pass | |
| if: >- | |
| github.event.pull_request.draft == false && | |
| steps.author-permission.outputs.can-push == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| run: | | |
| gh pr merge --auto --merge "$PR_URL" |