File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Approve PR
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ pr_number :
7+ description : PR number
8+ required : true
9+
10+ jobs :
11+ approve_pr :
12+ environment : pull-request
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout
17+ uses : actions/checkout@v4
18+
19+ - name : Get actors info
20+ id : actor_info
21+ run : |
22+ PR_AUTHOR=$(gh pr view ${{ inputs.pr_number }} --repo flathub/com.devolutions.remotedesktopmanager --json author -q '.author.login')
23+
24+ APPROVER=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
25+ "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/approvals")
26+ APPROVER_LOGIN=$(echo $APPROVER | jq -r '.[0].user.login')
27+
28+ echo "approver=$APPROVER_LOGIN" >> $GITHUB_OUTPUT
29+ echo "author=$PR_AUTHOR" >> $GITHUB_OUTPUT
30+ env :
31+ GH_TOKEN : ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
32+
33+ - name : Validate Approver
34+ run : |
35+ if [ "${{ steps.actor_info.outputs.author }}" == "${{ steps.actor_info.outputs.approver }}" ]; then
36+ echo "::error:: You can't approve your own PR"
37+ exit 1
38+ fi
39+
40+ - name : Merge pull request
41+ run : |
42+ echo "Waiting for checks to start..."
43+ sleep 120
44+ echo "Checking if checks have started..."
45+ gh pr checks ${{ inputs.pr_number }} --repo flathub/com.devolutions.remotedesktopmanager --watch --fail-fast
46+ gh pr merge ${{ inputs.pr_number }} --repo flathub/com.devolutions.remotedesktopmanager --squash --delete-branch --admin
47+ env :
48+ GH_TOKEN : ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
You can’t perform that action at this time.
0 commit comments