Skip to content

Commit 7edbbfa

Browse files
BigLepclaude
andauthored
ci: add automated issue/PR labeling and project board management (#82)
* ci: add workflows for auto-labeling and project board management Add two GitHub Actions workflows: - auto-label.yml: Automatically applies team/fs-wg and team/filecoin-pin labels to new issues and PRs - add-issues-and-prs-to-fs-project-board.yml: Adds labeled issues/PRs to the FS project board 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: use PAT in auto-label workflow to trigger project board workflow Use FILOZZY_CI_ADD_TO_PROJECT secret instead of default GITHUB_TOKEN to ensure that when labels are added, the add-issues-and-prs-to-fs-project-board workflow is properly triggered. Actions using GITHUB_TOKEN do not trigger subsequent workflows by design. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: add PAT requirements to auto-label workflow Document the specific requirements for the FILOZZY_CI_ADD_TO_PROJECT secret: - Must have public_repo scope to add labels to issues/PRs - PAT owner must have at least triage access to the repository 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: correct misleading comment about pull_request_target and secrets The previous comment incorrectly stated that fork PRs don't have access to secrets. In reality, pull_request_target DOES have access to secrets (unlike pull_request), which is precisely why it's being used here - to authenticate with the project board API for fork PRs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: clarify pull_request_target runs workflow from base branch Add security note explaining that pull_request_target executes the workflow file from the base branch (main), not from the PR branch. This prevents attackers from modifying the workflow via PR to steal secrets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * dod fix --------- Co-authored-by: Claude <[email protected]>
1 parent 3cb9df7 commit 7edbbfa

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
######################################################################################
2+
# READ THIS FIRST
3+
# This file is authored in filecoin-project/github-mgmt repository and MANUALLY copied to other repos.
4+
# See https://github.com/filecoin-project/github-mgmt/blob/master/files/.github/workflows/add-issues-and-prs-to-fs-project-board.yml for more info.
5+
######################################################################################
6+
7+
# This action adds all issues and PRs with a "team/fs-wg" label to the FS project board.
8+
# It is used to keep the FS project board up to date with the issues and PRs.
9+
# It is triggered by the issue and PR events.
10+
# It assumes a `FILOZZY_CI_ADD_TO_PROJECT` secret is set in the repo.
11+
# This secret should have the permissions outlined in https://github.com/actions/add-to-project?tab=readme-ov-file#creating-a-pat-and-adding-it-to-your-repository
12+
name: Add issues and PRs to FS project board
13+
14+
on:
15+
issues:
16+
types:
17+
- labeled
18+
# Using "pull_request_target" instead of "pull_request" to support PRs from forks.
19+
# pull_request_target has access to secrets even for fork PRs, which is necessary
20+
# for this action to authenticate and add items to the project board.
21+
# pull_request_target runs the workflow file from the base branch (main),
22+
# not from the PR branch, so attackers cannot modify this workflow via PR.
23+
# This action does not check out nor execute user code so we should be safe.
24+
# We also hardcode to specific hash to ensure no unintended changes underneath us.
25+
pull_request_target:
26+
types:
27+
- labeled
28+
29+
jobs:
30+
add-to-project:
31+
name: Add all "team/fs-wg" issues and PRs to project
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
35+
with:
36+
project-url: https://github.com/orgs/FilOzone/projects/14
37+
github-token: ${{ secrets.FILOZZY_CI_ADD_TO_PROJECT }}
38+
labeled: team/fs-wg

.github/workflows/auto-label.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Auto-label issues and PRs
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
pull_request:
7+
types: [opened]
8+
9+
jobs:
10+
label:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: write
15+
steps:
16+
- uses: actions/github-script@v7
17+
with:
18+
# Use PAT instead of default GITHUB_TOKEN to trigger subsequent workflows.
19+
# Events triggered by GITHUB_TOKEN do not create new workflow runs by design.
20+
# This allows the add-issues-and-prs-to-fs-project-board.yml workflow to be triggered when labels are added.
21+
# See: https://docs.github.com/en/actions/concepts/security/github_token
22+
#
23+
# PAT Requirements:
24+
# - Scope: public_repo (to add labels to issues/PRs in public repositories)
25+
# - Permissions: The PAT owner must have at least triage access to the repository
26+
github-token: ${{ secrets.FILOZZY_CI_ADD_TO_PROJECT }}
27+
script: |
28+
github.rest.issues.addLabels({
29+
issue_number: context.issue.number,
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
labels: ['team/fs-wg', 'team/filecoin-pin']
33+
})

0 commit comments

Comments
 (0)