self-approval.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Flow for self-approving the PRs, used by maintainers for cases aligned between them.
  2. # To trigger it, the maintainer needs to commit and push:
  3. # $ git commit -m "self-approval" --allow-empty
  4. name: Self Approval
  5. on:
  6. - pull_request_target
  7. permissions:
  8. pull-requests: write
  9. contents: write
  10. jobs:
  11. automate:
  12. name: Automate
  13. runs-on: ubuntu-latest
  14. if: ${{ contains(fromJson('["julienfalque", "keradus", "keradus-ci", "kubawerlos", "localheinz", "Wirone"]'), github.actor) }}
  15. env:
  16. PR_URL: ${{github.event.pull_request.html_url}}
  17. GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
  18. MARKER: "self-approval"
  19. steps:
  20. - name: Checkout
  21. uses: actions/checkout@v4
  22. with:
  23. ref: ${{ github.event.after }}
  24. - name: Determine whether PR should be automatically approved
  25. id: marker
  26. run: |
  27. msg=$(git show -s --format=%s ${{ github.event.after }})
  28. echo $msg
  29. indicator=$([[ $msg == $MARKER ]] && echo yes || echo no)
  30. echo $indicator
  31. echo "indicator_value=${indicator}" >> "$GITHUB_OUTPUT"
  32. - name: Approve pull request
  33. if: steps.marker.outputs.indicator_value == 'yes'
  34. run: |
  35. gh pr review --approve "$PR_URL"
  36. echo "Approval from GH Bot - PR is now mergeable, use it wisely!"