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 Issue to GitHub Project (v2) | |
on: | |
issues: | |
types: [opened] # Trigger when a new issue is opened | |
jobs: | |
add_to_project: | |
runs-on: ubuntu-latest # Use the latest Ubuntu runner | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 # Checkout the repository to work with | |
- name: Add issue to GitHub Project (v2) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use GitHub token to authenticate | |
run: | | |
# Define the Project ID where the issue should be added | |
PROJECT_ID="8" # Replace with your actual GitHub Project ID | |
ISSUE_NUMBER="${{ github.event.issue.number }}" # Get the number of the opened issue | |
# GitHub API call to add the issue to the project without specifying a column | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-d '{ | |
"content_id": '"$ISSUE_NUMBER"', | |
"content_type": "Issue" | |
}' \ | |
"https://api.github.com/projects/${PROJECT_ID}/items" |