Skip to content

Commit

Permalink
CI: allow for self-approvals for maintainers (#7921)
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Apr 5, 2024
1 parent 7eb5ec3 commit 5175075
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.github/CODEOWNERS @keradus
.github/workflows/self-approval.yml @keradus
41 changes: 41 additions & 0 deletions .github/workflows/self-approval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Flow for self-approving the PRs, used by maintainers for cases aligned between them.
# To trigger it, the maintainer needs to commit and push:
# $ git commit -m "self-approval" --allow-empty

name: Self Approval

on:
- pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
automate:
name: Automate
runs-on: ubuntu-latest
if: ${{ contains(fromJson('["julienfalque", "keradus", "keradus-ci", "kubawerlos", "localheinz", "Wirone"]'), github.actor) }}
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
MARKER: "self-approval"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.after }}
- name: Determine whether PR should be automatically approved
id: marker
run: |
msg=$(git show -s --format=%s ${{ github.event.after }})
echo $msg
indicator=$([[ $msg == $MARKER ]] && echo yes || echo no)
echo $indicator
echo "indicator_value=${indicator}" >> "$GITHUB_OUTPUT"
- name: Approve and enable auto-merge
if: steps.marker.outputs.indicator_value == 'yes'
run: |
echo self-approving
gh pr review --approve "$PR_URL"
gh pr merge --auto --squash "$PR_URL"

0 comments on commit 5175075

Please sign in to comment.