From cb979f38c0b1a4fb54c61e6215617500c8ed340f Mon Sep 17 00:00:00 2001 From: Mathias Vanden Auweele Date: Thu, 19 Nov 2026 21:09:03 +0000 Subject: [PATCH 1/5] ci: add issues and pull requests to the TripleTrail project New, reopened and transferred issues and pull requests are added to the organisation project as they come in. A manual run adds every existing one, open and closed. Needs the organisation secret PROJECT_TOKEN. --- .github/workflows/project.yml | 87 +++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/project.yml diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml new file mode 100644 index 0000000..562147f --- /dev/null +++ b/.github/workflows/project.yml @@ -0,0 +1,87 @@ +# Adds every issue and pull request of this repository to the organisation's +# TripleTrail project (https://github.com/orgs/Matdata-eu/projects/2). +# +# - New, reopened and transferred issues and pull requests are added as they +# come in. The project's own "Item added" workflow then sets their Status. +# - Run it by hand (Actions -> Project -> Run workflow) to add every existing +# issue and pull request, open and closed. Adding one that is already on the +# project changes nothing, so a second run is harmless. +# +# GITHUB_TOKEN cannot write to an organisation project, so this needs the +# organisation secret PROJECT_TOKEN: a fine-grained personal access token with +# resource owner Matdata-eu, organisation permission "Projects: Read and write", +# and repository permissions "Issues: Read" and "Pull requests: Read" on the +# TripleTrail repositories. +name: Project + +on: + issues: + types: [opened, reopened, transferred] + # pull_request_target so that pull requests from forks get the secret too. + # The job checks out no code, so nothing from the pull request runs. + pull_request_target: + types: [opened, reopened] + workflow_dispatch: + +permissions: {} + +concurrency: + group: project-${{ github.event.issue.number || github.event.pull_request.number || 'backfill' }} + +env: + PROJECT_OWNER: Matdata-eu + PROJECT_NUMBER: 2 + +jobs: + add: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/github-script@v7 + with: + github-token: ${{ secrets.PROJECT_TOKEN }} + script: | + const project = await github.graphql( + `query($login: String!, $number: Int!) { + organization(login: $login) { projectV2(number: $number) { id } } + }`, + { login: process.env.PROJECT_OWNER, number: Number(process.env.PROJECT_NUMBER) } + ); + const projectId = project.organization.projectV2.id; + + const add = async (contentId, label) => { + await github.graphql( + `mutation($project: ID!, $content: ID!) { + addProjectV2ItemById(input: { projectId: $project, contentId: $content }) { item { id } } + }`, + { project: projectId, content: contentId } + ); + core.info(`added ${label}`); + }; + + if (context.eventName !== 'workflow_dispatch') { + const item = context.payload.issue || context.payload.pull_request; + await add(item.node_id, `#${item.number}`); + return; + } + + // Backfill. The issues endpoint lists pull requests too, but under + // their issue id, so pull requests come from their own endpoint. + const options = { ...context.repo, state: 'all', per_page: 100 }; + const issues = (await github.paginate(github.rest.issues.listForRepo, options)) + .filter((issue) => !issue.pull_request); + const pulls = await github.paginate(github.rest.pulls.list, options); + const items = [...issues, ...pulls].sort((a, b) => a.number - b.number); + let failed = 0; + for (const item of items) { + try { + await add(item.node_id, `#${item.number}`); + // Stay under GitHub's limit on mutations per minute. + await new Promise((resolve) => setTimeout(resolve, 1000)); + } catch (error) { + failed += 1; + core.warning(`#${item.number}: ${error.message}`); + } + } + core.notice(`${items.length - failed} of ${items.length} issues and pull requests are on the project`); + if (failed) core.setFailed(`${failed} could not be added`); From 5445e751589c948dacb4c2b70eccf20c07ff2e2f Mon Sep 17 00:00:00 2001 From: Mathias Vanden Auweele Date: Thu, 19 Nov 2026 21:18:06 +0000 Subject: [PATCH 2/5] ci: drop the transferred trigger and move to github-script v8 A transferred issue fires in the repository it leaves, and the new repository already sees it as opened. github-script v8 runs on Node 24, which the runners now force anyway. The comment names the secret as a repository secret. --- .github/workflows/project.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 562147f..afe99fe 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -1,14 +1,15 @@ # Adds every issue and pull request of this repository to the organisation's # TripleTrail project (https://github.com/orgs/Matdata-eu/projects/2). # -# - New, reopened and transferred issues and pull requests are added as they +# - New and reopened issues and pull requests are added as they # come in. The project's own "Item added" workflow then sets their Status. # - Run it by hand (Actions -> Project -> Run workflow) to add every existing # issue and pull request, open and closed. Adding one that is already on the # project changes nothing, so a second run is harmless. # # GITHUB_TOKEN cannot write to an organisation project, so this needs the -# organisation secret PROJECT_TOKEN: a fine-grained personal access token with +# repository secret PROJECT_TOKEN (an organisation secret does not reach the +# private repositories on the organisation's plan): a fine-grained personal access token with # resource owner Matdata-eu, organisation permission "Projects: Read and write", # and repository permissions "Issues: Read" and "Pull requests: Read" on the # TripleTrail repositories. @@ -16,7 +17,7 @@ name: Project on: issues: - types: [opened, reopened, transferred] + types: [opened, reopened] # pull_request_target so that pull requests from forks get the secret too. # The job checks out no code, so nothing from the pull request runs. pull_request_target: @@ -37,7 +38,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/github-script@v7 + - uses: actions/github-script@v8 with: github-token: ${{ secrets.PROJECT_TOKEN }} script: | From 053bef7b140ba485071adcb45a677e4a9b48700c Mon Sep 17 00:00:00 2001 From: Mathias Vanden Auweele Date: Thu, 19 Nov 2026 21:19:04 +0000 Subject: [PATCH 3/5] ci: skip the project job when PROJECT_TOKEN is not set Without the secret, on a fork's pull request or before it is added, the job now prints a notice and passes instead of failing every pull request. --- .github/workflows/project.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index afe99fe..d82a063 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -8,8 +8,9 @@ # project changes nothing, so a second run is harmless. # # GITHUB_TOKEN cannot write to an organisation project, so this needs the -# repository secret PROJECT_TOKEN (an organisation secret does not reach the -# private repositories on the organisation's plan): a fine-grained personal access token with +# repository secret PROJECT_TOKEN, set in each repository (an organisation +# secret does not reach private repositories on the organisation's plan): a +# fine-grained personal access token with # resource owner Matdata-eu, organisation permission "Projects: Read and write", # and repository permissions "Issues: Read" and "Pull requests: Read" on the # TripleTrail repositories. @@ -37,10 +38,17 @@ jobs: add: runs-on: ubuntu-latest timeout-minutes: 30 + env: + PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} steps: - - uses: actions/github-script@v8 + # Without the secret (not set yet, or a pull request from a fork) the job + # passes without doing anything rather than failing every pull request. + - if: env.PROJECT_TOKEN == '' + run: echo "::notice::PROJECT_TOKEN is not set; nothing added" + - if: env.PROJECT_TOKEN != '' + uses: actions/github-script@v8 with: - github-token: ${{ secrets.PROJECT_TOKEN }} + github-token: ${{ env.PROJECT_TOKEN }} script: | const project = await github.graphql( `query($login: String!, $number: Int!) { From 571400d3e6a2adf4061cb843e26b070a3852ba4d Mon Sep 17 00:00:00 2001 From: Mathias Vanden Auweele Date: Thu, 19 Nov 2026 21:38:45 +0000 Subject: [PATCH 4/5] ci: set the board's Worker and Status from worker: and status: labels Threads and people without access to the project can claim an item by labelling it: worker:builder-1 sets Worker, status:blocked sets Status. The option name is matched in lower case with dashes for spaces. Removing the last worker: label clears Worker; unrelated labels leave fields set by hand on the board alone. --- .github/workflows/project.yml | 90 ++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 12 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index d82a063..2278e60 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -1,8 +1,17 @@ # Adds every issue and pull request of this repository to the organisation's -# TripleTrail project (https://github.com/orgs/Matdata-eu/projects/2). +# TripleTrail project (https://github.com/orgs/Matdata-eu/projects/2), and +# mirrors two kinds of labels into the project's fields. # -# - New and reopened issues and pull requests are added as they -# come in. The project's own "Item added" workflow then sets their Status. +# - New and reopened issues and pull requests are added as they come in. The +# project's own "Item added" workflow then sets their Status. +# - Labels set board fields, so anyone who can label an issue can claim it +# without access to the project: +# worker: