Skip to content

A GitHub Action that automatically closes or reopens issues if they are in specific project columns of a GitHub project.

License

Notifications You must be signed in to change notification settings

dasmerlon/project-issue-state-sync

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Issue State Sync

A GitHub Action that automatically closes or reopens issues if they are in a specific project column of a user- or organization-owned GitHub project (ProjectV2).

Note
This action does not support the old GitHub projects (classic).

Usage

Github projects come with built-in workflows that allow you to automatically move an issue to a specific project column when it's closed or reopened. For example, an issue is automatically moved to Done when it's closed. Unfortunately, the other way around is not supported, so the issue stays open when you move it to Done.

With this action you can specify the project columns in which issues should be closed or open. If an issue is in one of those project columns and has an undesired state, the action changes the issue state accordingly.

Inputs

Input variable Description Required
github_token The personal access token
owner The user or organization that owns the repository and project
project_number The number of the project you target
closed_statuses The project board column names in which issues should be closed
For example: Won't do,Done
(Make sure there are no spaces between arguments)
open_statuses The project board column names in which issues should be open
For example: Todo,In Progress
(Make sure there are no spaces between arguments)
verbosity The log output verbosity
Possible values: info, debug, trace
Default: info

Creating a PAT

Create a personal access token with following scopes and add it to your repository as a secret.

Note
This must be a personal access token (classic).
Fine grained PATs won't work.

Token scopes

  • repo
    • repo:status
    • repo_deployment
    • public_repo
    • repo:invite
    • security_events
  • project
    • read:project
  • admin:org
    • write:org
    • read:org (only needed if set up for an organization)
    • manage_runners:org

Creating a workflow

Create a workflow and save it as a .yml file in the .github/workflows/ directory of your target repository.

Supported Events

Unfortunately, GitHub only provides workflow trigger events for the older projects (classic). Therefore, there is no way to detect when an issue is moved to a different project column.

However, you can use a scheduled workflow to periodically check if issues have been moved and correct their states retrospectively.

  • The workflow_dispatch event allows you to manually trigger a workflow.

  • The schedule event allows you to trigger a workflow at a scheduled time.
    If you need help formulating the cron schedule expression, you can use crontab guru.

Example workflow

This workflow runs every 2 hours or if manually started.

name: Project Issue State Sync

on: 
  schedule:
    # At minute 0 every 2 hours
    - cron: 0 0-23/2 * * *
  
  workflow_dispatch:
    # Manual trigger

jobs:
  issue-state-sync:
    runs-on: ubuntu-latest

    steps:
      - name: Sync issue states
        uses: dasmerlon/project-issue-state-sync@v2
        with:
          github_token: ${{ secrets.PROJECT_ISSUE_SYNC_TOKEN }}
          owner: OWNER_NAME
          project_number: 1
          closed_statuses: Done
          open_statuses: Todo,In Progress

About

A GitHub Action that automatically closes or reopens issues if they are in specific project columns of a GitHub project.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •