Summary
Add a GitHub Actions workflow to automatically add newly opened issues to the relevant GitHub Project.
Why
Issues are not automatically captured by a project when they originate from multiple repositories. This workflow ensures newly opened issues are consistently added to the team project board without manual intervention.
Using a PROJECT_URL repository variable also makes the workflow reusable across repositories without hard-coding the project.
Proposed workflow
name: Add issue to project
on:
issues:
types: [opened]
permissions: {}
jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- name: Validate repository variable
run: |
if [[ -z "${{ vars.PROJECT_URL }}" ]]; then
echo "❌ PROJECT_URL repository variable is not set"
echo ""
echo "Required Action:"
echo "1. Go to: https://github.com/${{ github.repository }}/settings/variables"
echo "2. Click 'New repository variable'"
echo "3. Set Name: PROJECT_URL"
echo "4. Set Value: https://github.com/orgs/[ORG_NAME]/projects/[PROJECT_NUMBER]"
echo "5. Click 'Add variable'"
echo ""
exit 1
fi
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.PROJECT_HANDLER_BOT_APP_ID }}
private-key: ${{ secrets.PROJECT_HANDLER_BOT_PEM }}
owner: ${{ github.repository_owner }}
- uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
with:
project-url: ${{ vars.PROJECT_URL }}
github-token: ${{ steps.app-token.outputs.token }}
Acceptance criteria
Summary
Add a GitHub Actions workflow to automatically add newly opened issues to the relevant GitHub Project.
Why
Issues are not automatically captured by a project when they originate from multiple repositories. This workflow ensures newly opened issues are consistently added to the team project board without manual intervention.
Using a
PROJECT_URLrepository variable also makes the workflow reusable across repositories without hard-coding the project.Proposed workflow
Acceptance criteria
PROJECT_URL.PROJECT_URLis not configured.PROJECT_HANDLER_BOT_APP_IDandPROJECT_HANDLER_BOT_PEMsecrets are used.