PR management #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |