Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINOR Remove triage label in nightly job #18147

Merged
merged 20 commits into from
Dec 18, 2024
10 changes: 4 additions & 6 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ Unlike trunk, the PR builds _will_ utilize the Gradle cache.
### PR Triage

In order to get the attention of committers, we have a triage workflow for Pull Requests
opened by non-committers. This workflow consists of three files:
opened by non-committers. This workflow consists of two files:

* [pr-update.yml](pr-update.yml) When a PR is created add the `triage` label if the PR
* [pr-update.yml](pr-update.yml) When a PR is created, add the `triage` label if the PR
was opened by a non-committer.
* [pr-reviewed-trigger.yml](pr-reviewed-trigger.yml) Runs when any PR is reviewed.
Used as a trigger for the next workflow
* [pr-reviewed.yml](pr-reviewed.yml) Remove the `triage` label after a PR has been reviewed
* [pr-reviewed.yml](pr-reviewed.yml) Cron job to remove the `triage` label from PRs which have been reviewed

_The pr-update.yml workflow includes pull_request_target!_

Expand All @@ -100,7 +98,7 @@ There are two files related to this workflow:

* [pr-labeled.yml](pr-labeled.yml) approves a pending approval for PRs that have
been labeled with `ci-approved`
* [ci-requested.yml](ci-requested.yml) approves future CI requests automatically
* [ci-requested.yml](ci-requested.yml) approves future workflow requests automatically
if the PR has the `ci-approved` label

_The pr-labeled.yml workflow includes pull_request_target!_
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/pr-reviewed-trigger.yml

This file was deleted.

49 changes: 29 additions & 20 deletions .github/workflows/pr-reviewed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,48 @@
name: Remove Triage Label

on:
workflow_run:
workflows: [Pull Request Reviewed]
types:
- completed
workflow_dispatch: # Let us run manually

schedule:
- cron: '0 3 * * *' # Run at 3:00 UTC nightly -- just before the "stale.yml" workflow

jobs:
# This job runs with elevated permissions and the ability to modify pull requests. The steps taken here
# should be limited to updating labels and adding comments to PRs. This approach is taken from
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/.
remove-triage:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Env
run: printenv
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- uses: actions/download-artifact@v4
with:
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}
name: pr-number.txt
- name: Remove label
uses: actions/github-script@v7
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var pr_number = Number(fs.readFileSync('./pr-number.txt'));
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
name: 'triage'
github.paginate("GET /search/issues{?q}", {
q: "repo:apache/kafka label:triage is:pull-request"
})
.then((pulls) => {
pulls.forEach(pull => {
github.request("GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews", {
owner: "apache",
repo: "kafka",
pull_number: pull.number,
headers: {
"X-GitHub-Api-Version": "2022-11-28"
}
}).then((resp) => {
console.log("Found " + resp.data.length + " reviews for PR " + pull.number);
if (resp.data.length > 0) {
console.log("Removing 'triage' label from PR " + pull.number + " : " + pull.title);
github.rest.issues.removeLabel({
owner: "apache",
repo: "kafka",
issue_number: pull.number,
name: "triage"
});
}
});
});
});
Loading