Skip to content

Add Add issue to project workflow #68

Description

@ColinDaglish

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

  • Newly opened issues are automatically added to the project specified by PROJECT_URL.
  • The workflow fails with a clear message if PROJECT_URL is not configured.
  • Existing PROJECT_HANDLER_BOT_APP_ID and PROJECT_HANDLER_BOT_PEM secrets are used.
  • Actions are pinned to the specified commit SHAs.
  • A test issue confirms the workflow successfully adds an issue to the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions