Document the process for adding ADD_TO_PROJECT_PAT
token
#10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Add issues to project board | |
on: | |
# Allow this workflow to be called by another workflow | |
workflow_call: | |
inputs: | |
project-url: | |
description: 'The URL of the project board to add the issue to' | |
required: true | |
type: string | |
secrets: | |
GITHUB_PAT: | |
description: 'The github token with permissions to add issues to the project' | |
required: true | |
# The caller should use these triggers on their workflow file | |
issues: | |
types: | |
- opened | |
env: | |
# We use this workflow locally for hugrverse-actions issues. | |
# This variable detects whether we are running the workflow locally or via an external workflow_call. | |
# | |
# Github's terrible version of a 'ternary operator' | |
# https://github.com/actions/runner/issues/409#issuecomment-752775072 | |
PROJECT_URL: ${{ github.repository == 'CQCL/hugrverse-actions' && 'https://github.com/orgs/CQCL-DEV/projects/10' || inputs.project-url }} | |
# We use a ADD_TO_PROJECT_PAT secret locally. | |
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT || secrets.ADD_TO_PROJECT_PAT }} | |
jobs: | |
add-to-project: | |
name: Add issue to project | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fail if project-url is not set | |
if: env.PROJECT_URL == '' | |
run: | | |
echo "The project-url input is required." | |
exit 1 | |
- name: Fail if GITHUB_PAT is not set | |
if: env.GITHUB_TOKEN == '' | |
run: | | |
echo "The GITHUB_PAT input is required." | |
exit 1 | |
- uses: actions/[email protected] | |
with: | |
project-url: ${{ env.PROJECT_URL }} | |
github-token: ${{ env.GITHUB_TOKEN }} |