Skip to content

Commit 5175075

Browse files
authored
CI: allow for self-approvals for maintainers (#7921)
1 parent 7eb5ec3 commit 5175075

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.github/CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.github/CODEOWNERS @keradus
2+
.github/workflows/self-approval.yml @keradus

.github/workflows/self-approval.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
5+
name: Self Approval
6+
7+
on:
8+
- pull_request_target
9+
10+
permissions:
11+
pull-requests: write
12+
contents: write
13+
14+
jobs:
15+
automate:
16+
name: Automate
17+
runs-on: ubuntu-latest
18+
if: ${{ contains(fromJson('["julienfalque", "keradus", "keradus-ci", "kubawerlos", "localheinz", "Wirone"]'), github.actor) }}
19+
env:
20+
PR_URL: ${{github.event.pull_request.html_url}}
21+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
MARKER: "self-approval"
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.after }}
28+
- name: Determine whether PR should be automatically approved
29+
id: marker
30+
run: |
31+
msg=$(git show -s --format=%s ${{ github.event.after }})
32+
echo $msg
33+
indicator=$([[ $msg == $MARKER ]] && echo yes || echo no)
34+
echo $indicator
35+
echo "indicator_value=${indicator}" >> "$GITHUB_OUTPUT"
36+
- name: Approve and enable auto-merge
37+
if: steps.marker.outputs.indicator_value == 'yes'
38+
run: |
39+
echo self-approving
40+
gh pr review --approve "$PR_URL"
41+
gh pr merge --auto --squash "$PR_URL"

0 commit comments

Comments
 (0)