Skip to content

Commit

Permalink
Update main.yml (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodjima33 authored Jun 20, 2024
2 parents 48d852f + ad10d2d commit 840dff6
Showing 1 changed file with 32 additions and 43 deletions.
75 changes: 32 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,40 @@
name: Add issue to project on label "task"
name: GitHub Issue Sync

on:
issues:
types: [labeled]
types:
- opened
- labeled
workflow_dispatch:
inputs:
excludeClosed:
description: 'Exclude closed issues in the sync.'
type: boolean
default: true

jobs:
add_to_project:
if: github.event.label.name == 'task'
sync:
runs-on: ubuntu-latest

steps:
- name: Add issue to project
uses: actions/github-script@v6
- name: Sync issues
uses: paritytech/github-issue-sync@master
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'
});
# This token is autogenerated by GitHub
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This is a Personal Access Token and it needs to have the following permissions
# - "read:org": used to read the project's board
# - "write:org": used to assign issues to the project's board
PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }}
# The number of the project which the issues will be synced to
# You can find this in https://github.com/orgs/@ORGANIZATION/projects/<NUMBER>
project: 1
# Optional, the project field to modify with a new value
# Found more in https://docs.github.com/en/issues/planning-and-tracking-with-projects/understanding-fields/about-single-select-fields
project_field: Status
# Optional unless that project_field was set up. Then this field is required.
# The value to modify in the project field
project_value: Backlog
# Optional, labels to work with. Read below to see how to configure it.
# If this value is set, the action will be applied only to issues with such label(s).
labels: |
task

0 comments on commit 840dff6

Please sign in to comment.