|
| 1 | +# Puts every new issue and pull request on the org-wide "Vstorm OSS" board so |
| 2 | +# nothing arrives in a repo nobody is watching that week. |
| 3 | +# |
| 4 | +# https://github.com/orgs/vstorm-co/projects/12 |
| 5 | +# |
| 6 | +# The board's own automation cannot do this: GitHub's built-in "Auto-add to |
| 7 | +# project" workflow is configured per repository and the number of them a project |
| 8 | +# may have is capped by the org plan, so six repos do not fit. This action does. |
| 9 | +# |
| 10 | +# SETUP (once, at the organization): a PAT with the `project` scope, stored as the |
| 11 | +# organization secret ADD_TO_PROJECT_PAT and shared with this repository. The |
| 12 | +# workflow's own GITHUB_TOKEN cannot be used - it has no access to organization |
| 13 | +# projects, only to this repo. |
| 14 | +# |
| 15 | +# WHY `pull_request_target` AND WHY IT IS SAFE HERE. These are public repos, so |
| 16 | +# most pull requests come from forks - and `pull_request` gives a fork run no |
| 17 | +# secrets, which means no PAT and no board entry for exactly the contributions |
| 18 | +# worth tracking. `pull_request_target` runs with the base repo's secrets, which |
| 19 | +# is normally the dangerous choice. It is safe in this one because the job never |
| 20 | +# touches the contributor's code: there is no checkout, no build, no script from |
| 21 | +# the PR. It reads two numbers from the event and calls one pinned action. If a |
| 22 | +# step is ever added here that checks the PR out, this trigger must change. |
| 23 | +name: Add to Vstorm OSS project |
| 24 | + |
| 25 | +on: |
| 26 | + issues: |
| 27 | + types: [opened, reopened, transferred] |
| 28 | + pull_request_target: |
| 29 | + types: [opened, reopened, ready_for_review] |
| 30 | + |
| 31 | +# Nothing here writes through GITHUB_TOKEN; the PAT does the one write there is. |
| 32 | +permissions: {} |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: add-to-project-${{ github.event.issue.number || github.event.pull_request.number }} |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +jobs: |
| 39 | + add: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + # Skip cleanly while the secret is absent rather than failing. These are |
| 42 | + # public repositories: a red cross on every issue somebody opens is a worse |
| 43 | + # first impression than a board that is briefly incomplete. The job starts |
| 44 | + # working by itself the moment ADD_TO_PROJECT_PAT exists - nothing to merge |
| 45 | + # again. |
| 46 | + if: ${{ vars.DISABLE_ADD_TO_PROJECT != 'true' }} |
| 47 | + steps: |
| 48 | + - name: Check the project token is configured |
| 49 | + id: token |
| 50 | + env: |
| 51 | + PAT: ${{ secrets.ADD_TO_PROJECT_PAT }} |
| 52 | + run: | |
| 53 | + if [ -z "$PAT" ]; then |
| 54 | + echo "configured=false" >> "$GITHUB_OUTPUT" |
| 55 | + echo "::notice::ADD_TO_PROJECT_PAT is not set for this repository - skipping. See the header of this workflow for setup." |
| 56 | + else |
| 57 | + echo "configured=true" >> "$GITHUB_OUTPUT" |
| 58 | + fi |
| 59 | +
|
| 60 | + # Pinned to v2.0.0 by commit. Bump deliberately; do not track a moving tag. |
| 61 | + - name: Add to project |
| 62 | + if: steps.token.outputs.configured == 'true' |
| 63 | + uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0 |
| 64 | + with: |
| 65 | + project-url: https://github.com/orgs/vstorm-co/projects/12 |
| 66 | + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} |
0 commit comments