diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml deleted file mode 100644 index afad000c7..000000000 --- a/.github/workflows/issues.yml +++ /dev/null @@ -1,22 +0,0 @@ -on: - issues: - types: [opened] -name: Issue triage -jobs: - markIssuesForTriage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - name: Apply Issue needs-triage Label - if: github.event.action == 'opened' && !contains(fromJSON('["breathingdust", "ewbankkit", "gdavison", "johnsonaj", "YakDriver", "zhelding"]'), github.actor) - uses: github/issue-labeler@c1b0f9f52a63158c4adc09425e858e87b32e9685 # v3.4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - configuration-path: .github/labeler-issue-needs-triage.yml - enable-versioned-regex: 0 - - name: Apply Issue Triage Labels - uses: github/issue-labeler@c1b0f9f52a63158c4adc09425e858e87b32e9685 # v3.4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - configuration-path: .github/labeler-issue-triage.yml - enable-versioned-regex: 0 diff --git a/.github/workflows/labelers.yml b/.github/workflows/labelers.yml new file mode 100644 index 000000000..8e83df380 --- /dev/null +++ b/.github/workflows/labelers.yml @@ -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 diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml deleted file mode 100644 index bafb11bab..000000000 --- a/.github/workflows/pull_requests.yml +++ /dev/null @@ -1,15 +0,0 @@ -on: - - pull_request_target - -name: Pull Request Target (All types) -jobs: - NeedsTriageLabeler: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - name: Apply needs-triage Label - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 - if: github.event.action == 'opened' && !contains(fromJSON('["breathingdust", "ewbankkit", "gdavison", "johnsonaj", "YakDriver", "zhelding"]'), github.actor) - with: - configuration-path: .github/labeler-pr-needs-triage.yml - repo-token: ${{ secrets.GITHUB_TOKEN }}