-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Add PR triage workflow #17881
Add PR triage workflow #17881
Changes from all commits
c3efb25
003b14e
60df0cd
a771e75
0350b04
fae4258
8961db8
9fe6121
883f103
35a47bc
cfec4b2
3211290
22c5b26
34eecff
00b96f7
b954ae0
59fd693
3ce7173
090088a
935bd12
2833884
ecd5eab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Pull Request Reviewed | ||
|
||
on: | ||
pull_request_review: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This event brings a interesting race condition:
Perhaps the issue is invalid, as pull requests should not be approved before the CI process completes. 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filed #18200 to (hopefully) fix this |
||
types: | ||
- submitted | ||
|
||
jobs: | ||
# This job is a workaround for the fact that pull_request_review lacks necessary permissions to modify PRs. | ||
# Also, there is no pull_request_target analog to pull_request_review. The approach taken here is taken from | ||
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/. | ||
pr-review-trigger: | ||
name: Reviewed | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Env | ||
run: printenv | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
- name: Capture PR Number | ||
run: | ||
echo ${{ github.event.pull_request.number }} >> pr-number.txt | ||
- name: Archive Event | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pr-number.txt | ||
path: pr-number.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Remove Triage Label | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Pull Request Reviewed] | ||
types: | ||
- completed | ||
|
||
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 | ||
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' | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're starting to have quite a few actions. I think it would be good to add the
description
field to all of them to clearly state their role, how they work, and the potential relationships between each others.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a description field for the workflow files. I've been adding comments here and there to help people navigate the workflow files. I think
name
is as good as we get unfortunately.Here's the docs: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows
And a similar question on SO: https://stackoverflow.com/questions/70941956/description-for-a-workflow-in-github-actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad I was looking at https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#description which is not available for workflows.
So let's use comments to describe the workflows. Maybe it's only me (I'm not super familiar with GitHub Actions) but looking at the files (without reading the PR), it's not immediately obvious what each one does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added some docs to the README in the .github/workflows directory. PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks that's very helpful!