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

Add PR triage workflow for community issues #55

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:
secrets:
UPBOUND_BOT_GITHUB_TOKEN:
description: 'A PAT with permissions that allow adding issues to a project'
description: 'A PAT with permissions that allow labeling and adding issues to a project'
required: true

jobs:
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Debug
run: |
echo "github.event.issue.author_association: ${{ github.event.issue.author_association }}"
community_issue_triage:
community-issue-triage:
if: ${{ (github.event.issue.author_association != 'OWNER' &&
github.event.issue.author_association != 'MEMBER' &&
github.event.issue.author_association != 'CONTRIBUTOR' &&
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/pr-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Pull Request Triage

on:
workflow_call:
secrets:
UPBOUND_BOT_GITHUB_TOKEN:
description: 'A PAT with permissions that allow labeling and adding PRs to a project'
required: true

jobs:
debug:
runs-on: ubuntu-22.04
steps:
- name: Debug
run: |
echo "github.event.pull_request.author_association: ${{ github.event.pull_request.author_association }}"
community-pr-triage:
if: ${{ (github.event.pull_request.author_association != 'OWNER' &&
github.event.pull_request.author_association != 'MEMBER' &&
github.event.pull_request.author_association != 'CONTRIBUTOR' &&
github.event.pull_request.author_association != 'COLLABORATOR' ) }}
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Label as community PR
if: ${{ !contains(github.event.pull_request.labels.*.name, 'community') }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we label PRs using the github.rest.issues.addLabels API? I see the event now mentions pull_request (contains(github.event.pull_request.labels.*.name... above). I think we have already validated this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, unfortunately, this is very confusing due to the naming but GitHub treats PRs/Issues as a similar object it seems. There isn't a corresponding github.rest.pulls.addLabels API.

issue_number: github.event.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["community"]
})
- name: Add PR to Extensions Community Support project
uses: actions/[email protected]
with:
project-url: https://github.com/orgs/upbound/projects/104/views/1
github-token: ${{ secrets.UPBOUND_BOT_GITHUB_TOKEN }}