Automate development and production releases [$700] #3
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 project on label "task" | |
on: | |
issues: | |
types: [labeled] | |
jobs: | |
add_to_project: | |
if: github.event.label.name == 'task' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Add issue to project | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const projectNumber = 1; // Replace with your project number | |
const columnName = 'Backlog'; // Replace with your target column name | |
// Fetch the list of projects for the repository | |
const { data: projects } = await github.rest.projects.listForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open' | |
}); | |
// Find the project by number | |
const project = projects.find(proj => proj.number === projectNumber); | |
if (!project) { | |
throw new Error(`Project number ${projectNumber} not found.`); | |
} | |
// Fetch the list of columns for the project | |
const { data: columns } = await github.rest.projects.listColumns({ | |
project_id: project.id | |
}); | |
// Find the column by name | |
const column = columns.find(col => col.name === columnName); | |
if (!column) { | |
throw new Error(`Column '${columnName}' not found in project ${projectNumber}.`); | |
} | |
// Add the issue to the column | |
await github.rest.projects.createCard({ | |
column_id: column.id, | |
content_id: context.issue.id, | |
content_type: 'Issue' | |
}); |