-
Notifications
You must be signed in to change notification settings - Fork 8
102 lines (85 loc) · 4.91 KB
/
pr_management.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Auto Label PRs, then add assignees and reviewers automatically.
run-name: PR management stuff
on:
pull_request_target:
types: [opened, reopened, ready_for_review, edited, synchronize, labeled]
permissions:
pull-requests: write
jobs:
add_labels_reviewers_assignees:
name: Add labels, reviewers & assignees
runs-on: ubuntu-latest
steps:
- name: Auto-assign PR author as assignee
if: github.event.action == 'opened' || github.event.action == 'reopened'
id: author-assignee
uses: itsOliverBott/assign-pr-author-as-assignee@release
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Label PR based on content
if: github.event.action != 'labeled'
id: label-pr
uses: fuxingloh/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-path: .github/labeler.yml
- name: Label & comment if PR has conflict
uses: eps1lon/[email protected]
with:
dirtyLabel: "Merge conflict identified"
repoToken: "${{ secrets.GITHUB_TOKEN }}"
commentOnDirty: "This pull request has conflicts with the base branch, which is ${{ github.base_ref }}. Please resolve them."
commentOnClean: "Resolved conflicts!"
- name: Assign/unassign reviewers
if: github.event.action == 'ready_for_review'
id: assign-reviewers
uses: totallymoney/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
unassign-if-label-removed: true
- name: Comment on PRs
uses: dannyskoog/pull-request-comment@v1
if: steps.assign-reviewers.outputs.assigned_status == 'success' && steps.assign-reviewers.outputs.unassigned_status == 'success'
with:
message: I've labeled your PR, assigned you and requested/un-requested reviews from the relevant people automatically. If you think I did it wrong, please comment below so one of our maintainers can double-check. Thanks!
- name: Assigned/unassigned reviewers success debug log
if: steps.assign-reviewers.outputs.assigned_status == 'success' && steps.assign-reviewers.outputs.unassigned_status == 'success'
id: success-log
run: |
echo "Successfully assigned/unassigned reviewers! Printing more info below..."
echo "If values return null, that means I didn't do anything.\n"
echo "PR I assigned reviewers to: ${{ steps.assign-reviewers.outputs.assigned_url }}"
echo "Commit SHA: ${{ github.sha }}"
echo "I assigned: ${{ steps.assign-reviewers.outputs.assigned_reviewers }}"
echo "Additional info: ${{ steps.assign-reviewers.outputs.assigned_message }} \n"
echo "PR I unassigned reviewers to: ${{ steps.assign-reviewers.outputs.unassigned_url }}"
echo "Commit SHA: ${{ github.sha }}"
echo "I unassigned: ${{ steps.assign-reviewers.outputs.unassigned_reviewers }}"
echo "Additional info: ${{ steps.assign-reviewers.outputs.unassigned_message }}"
- name: Assigned/unassigned reviewers failure(?) debug log
if: steps.assign-reviewers.outputs.assigned_status == 'info' && steps.assign-reviewers.outputs.unassigned_status == 'info'
id: info-debug
run: |
echo "Uh-oh! I (probably) ran into an issue when assigning/unassigning reviewers! Here's some info: \n"
echo "PR I attempted to assign reviewers to: ${{ steps.assign-reviewers.outputs.assigned_url }}"
echo "Commit SHA: ${{ github.sha }}"
echo "Info: ${{ steps.assign-reviewers.outputs.assigned_message }} \n"
echo "PR I unassigned reviewers to: ${{ steps.assign-reviewers.outputs.unassigned_url }}"
echo "Commit SHA: ${{ github.sha }}"
echo "Info: ${{ steps.assign-reviewers.outputs.unassigned_message }}"
- name: Debug log if literally anything else fails
if: steps.author-assignee.outcome == 'failure' || steps.label-pr.outcome == 'failure' || steps.assign-reviewers.outcome == 'failure'
id: log-on-fail
run: |
echo "Failed to execute workflow correctly! Details are as follows:\n"
echo "Run attempt #${{ github.run_attempt }}"
echo "Triggered by ${{ github.triggering_actor }}"
echo "Merging ${{ github.base_ref }} <- ${{ github.head_ref }}"
echo "Triggering event: ${{ github.event }}\n"
echo "Check previous step logs, as well as the debug logs if necessary, for more info."
- name: Warn if this workflow fails
if: steps.author-assignee.outcome == 'failure' || steps.label-pr.outcome == 'failure' || steps.assign-reviewers.outcome == 'failure'
id: warn-on-fail
uses: dannyskoog/pull-request-comment@v1
with:
message: Something went wrong when managing this PR! Maintainers, please check the Actions log for more details and potential fixes.