Skip to content

Commit

Permalink
Merge pull request #1742 from hashicorp/introduce-labelers-workflow
Browse files Browse the repository at this point in the history
Introduce labelers workflow
  • Loading branch information
justinretzolk authored Jun 6, 2024
2 parents 2b31fdd + 13e7b30 commit 15b621f
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 37 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/issues.yml

This file was deleted.

132 changes: 132 additions & 0 deletions .github/workflows/labelers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Label Automations

permissions:
issues: write
pull-requests: write

on:
issues:
types:
- closed
- edited
- opened

issue_comment:
types:
- created

pull_request_target:
types:
- assigned
- closed
- edited
- opened

jobs:
repo_and_community:
name: Repository and Community Labels
runs-on: ubuntu-latest

env:
GH_CLI_SUBCOMMAND: ${{ (github.event.issue.pull_request || github.event.pull_request) && 'pr' || 'issue' }}
ISSUE_URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}
LABELS: ${{ toJSON(github.event.issue.labels.*.name || github.event.pull_request.labels.*.name) }}
MAINTAINERS: ${{ secrets.MAINTAINERS }}

steps:
- name: "Community Check: Author"
id: author
if: github.event.action == 'opened'
env:
AUTHOR_LOGIN: ${{ github.event.issue.user.login || github.event.pull_request.user.login }}
CORE_CONTRIBUTORS: ${{ secrets.CORE_CONTRIBUTORS }}
PARTNERS: ${{ secrets.PARTNERS }}
run: |
echo "is_core_contributor=$(echo $CORE_CONTRIBUTORS | base64 --decode | jq --arg u $AUTHOR_LOGIN '. | contains([$u])')" >> "$GITHUB_OUTPUT"
echo "is_maintainer=$(echo $MAINTAINERS | base64 --decode | jq --arg u $AUTHOR_LOGIN '. | contains([$u])')" >> "$GITHUB_OUTPUT"
echo "is_partner=$(echo $PARTNERS | base64 --decode | jq --arg u $AUTHOR_LOGIN '. | contains([$u])')" >> "$GITHUB_OUTPUT"
- name: Indicate That Triage is Required
if: |
steps.author.conclusion != 'skipped'
&& !fromJSON(steps.author.outputs.is_maintainer)
run: |
gh $GH_CLI_SUBCOMMAND edit "$ISSUE_URL" --add-label needs-triage
- name: Credit Core Contributor Contributions
if: |
github.event_name == 'pull_request_target'
&& steps.author.conclusion != 'skipped'
&& fromJSON(steps.author.outputs.is_core_contributor)
run: |
gh pr edit "$ISSUE_URL" --add-label external-maintainer
- name: Add prioritized to Maintainer Contributions
if: |
github.event_name == 'pull_request_target'
&& steps.author.conclusion != 'skipped'
&& fromJSON(steps.author.outputs.is_maintainer))
run: |
gh pr edit "$ISSUE_URL" --add-label prioritized
- name: Credit Partner Contributions
if: |
github.event_name == 'pull_request_target'
&& steps.author.conclusion != 'skipped'
&& fromJSON(steps.author.outputs.is_partner)
run: |
gh pr edit "$ISSUE_URL" --add-label partner
- name: "Community Check: Assignee"
id: assignee
if: github.event.action == 'assigned'
env:
ASSIGNEE_LOGIN: ${{ github.event.assignee.login }}
run: |
echo "is_maintainer=$(echo $MAINTAINERS | base64 --decode | jq --arg u $ASSIGNEE_LOGIN '. | contains([$u])')" >> "$GITHUB_OUTPUT"
- name: Add prioritized to Maintainer Assignments
if: |
steps.assignee.conclusion != 'skipped'
&& fromJSON(steps.assignee.outputs.is_maintainer))
run: |
gh $GH_CLI_SUBCOMMAND edit "$ISSUE_URL" --add-label prioritized
- name: "Community Check: Editor"
id: editor
if: github.event.action == 'edited'
env:
EDITOR_LOGIN: ${{ github.event.sender.login }}
run: |
echo "is_maintainer=$(echo $MAINTAINERS | base64 --decode | jq --arg u $ASSIGNEE_LOGIN '. | contains([$u])')" >> "$GITHUB_OUTPUT"
- name: Remove Stale Indicators on Non-Maintainer Edit
if: |
(steps.editor.conclusion != 'skipped' && !fromJSON(steps.editor.outputs.is_maintainer))
&& (contains(fromJSON(env.LABELS), 'stale') || contains(fromJSON(env.LABELS), 'waiting-response'))
run: |
gh $GH_CLI_SUBCOMMAND edit "$ISSUE_URL" --remove-label stale,waiting-response
- name: "Community Check: Commenter"
id: commenter
if: github.event.action == 'created'
env:
COMMENTER_LOGIN: ${{ github.event.comment.user.login }}
run: |
echo "is_maintainer=$(echo $MAINTAINERS | base64 --decode | jq --arg u $COMMENTER_LOGIN '. | contains([$u])')" >> "$GITHUB_OUTPUT"
- name: Remove Stale Indicators on Non-Maintainer Comment
if: |
(steps.commenter.conclusion != 'skipped' && !fromJSON(steps.commenter.outputs.is_maintainer))
&& (contains(fromJSON(env.LABELS), 'stale') || contains(fromJSON(env.LABELS), 'waiting-response'))
run: |
gh $GH_CLI_SUBCOMMAND edit "$ISSUE_URL" --remove-label stale,waiting-response
- name: Remove Triage Labels on Closure
if: |
github.event.action == 'closed'
&& (contains(fromJSON(env.LABELS), 'needs-triage') || contains(fromJSON(env.LABELS), 'waiting-response'))
run: |
gh $GH_CLI_SUBCOMMAND edit "$ISSUE_URL" --remove-label needs-triage,waiting-response
15 changes: 0 additions & 15 deletions .github/workflows/pull_requests.yml

This file was deleted.

0 comments on commit 15b621f

Please sign in to comment.