
project-sync-issues
Configure automatic synchronization between Issue/PR states and project Status. Mode A generates `.github/workflows/project-sync.yml` using the `Fandhe-AI/actions/project-sync` composite action (with a PAT or GitHub App token). Mode B batch-corrects existing inconsistencies. Use for cases such as setting up auto-sync, moving to In Review during PR reviews, or syncing board and Issue statuses.
Related Skills
Configure automatic synchronization between Issue/PR states and project Status. Mode A generates `.github/workflows/project-sync.yml` using the `Fandhe-AI/actions/project-sync` composite action (with a PAT or GitHub App token). Mode B batch-corrects existing inconsistencies. Use for cases such as setting up auto-sync, moving to In Review during PR reviews, or syncing board and Issue statuses.
project-sync-issues
Generates GitHub Actions workflow files to automatically synchronize Issue and PR status changes to a GitHub Project Status field. It also provides a manual batch-correction mode.
Prerequisites
- The target GitHub Project must be linked to the repository.
- The
ghCLI must be installed and authenticated with theprojectscope.
Flow
Prompt the user to confirm the execution mode:
- Auto-sync Setup: Generate a GitHub Actions workflow (recommended for initial setup).
- Manual Batch Correction: Batch-correct current inconsistencies (for ad-hoc single runs).
Mode A: Auto-sync Setup
Step A-1: Retrieve Project Information
# Get owner
gh repo view --json owner -q '.owner.login'
# Check project number
gh project list --owner <owner> --format json
Confirm the target project number with the user.
Step A-2: Guide Authentication Secret Configuration
Accessing the Projects API from GitHub Actions requires privileges beyond the default GITHUB_TOKEN. One of the following is required:
Option 1: Personal Access Token (for personal or small-scale use)
- Go to GitHub Settings → Developer settings → Personal access tokens → Fine-grained tokens.
- Required scopes:
project(read & write) +issues(read & write) +pull_requests(read & write). - Register as
PROJECT_TOKENunder Repository Settings → Secrets and variables → Actions.
Option 2: GitHub App Token (for organizations; recommended)
- Create a GitHub App and grant it
Projects: Read and writepermissions for the organization. - Generate a token inside the workflow using
actions/create-github-app-token.
Step A-3: Generate the GitHub Actions Workflow
Use the Fandhe-AI/actions/project-sync composite action to generate .github/workflows/project-sync.yml.
Reference Conventions (internal actions use @latest; third-party actions use pinned SHAs):
Fandhe-AI/actions/* (specifically project-sync in this skill) is an internally managed and reviewed action, so it uses the @latest tag reference as decided by ownership policy. Conversely, third-party actions (such as actions/create-github-app-token) must be pinned to a verified commit SHA rather than floating references like @main or @vN. Dynamically fetching the latest SHA on every generation propagates upstream compromises or unintentional modifications directly into the target environment. Therefore, use the reviewed pinned SHA below as a constant when generating workflows, without dynamically fetching the latest SHA:
| Action | Pinned SHA | Corresponding Version |
|---|---|---|
actions/create-github-app-token |
fee1f7d63c2ff003460e3d139729b119787bc349 |
v2.2.2 |
The SHA above was pinned after fetching and inspecting the actual code content (action.yml and all referenced scripts) at the time of adoption. Only when updating the SHA is required (not during routine workflow generation), follow these steps to inspect the actual changes before updating the constant and example workflow in this file (applies to third-party actions only; Fandhe-AI/actions/project-sync uses @latest and is excluded from SHA update steps):
# Fetch the latest target SHA candidate (run only during update tasks; e.g. actions/create-github-app-token)
gh api repos/actions/create-github-app-token/commits/main --jq '.sha'
# Retrieve and review the diff patch (the exact changes) against the old SHA. A file list alone is insufficient
gh api repos/actions/create-github-app-token/compare/<OLD_SHA>...<NEW_SHA> --jq '.files[] | {filename, patch}'
# Fetch action.yml and all referenced scripts at the new SHA state, then review them to verify no suspicious
# command additions or binary downloads exist
gh api repos/actions/create-github-app-token/contents/action.yml?ref=<NEW_SHA> --jq '.content' | base64 -d
Manually inspect the diff patch, action.yml, and referenced scripts to ensure there are no unintended changes or suspicious commands. Where applicable, verify commit signatures or release provenance (e.g. gh attestation verify). Update the pinned SHA table above and the inline version comment on the uses: line in subsequent workflow examples only after manual verification succeeds. Fandhe-AI/actions/project-sync uses @latest, so this inspection workflow is not required for it.
When using PAT:
name: Project Sync
on:
issues:
types: [opened, closed, reopened]
pull_request:
types: [opened, closed, ready_for_review, review_requested]
permissions:
contents: read
jobs:
sync:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Sync project status
uses: Fandhe-AI/actions/project-sync@latest
with:
project-number: '<number>'
project-owner: '<owner>'
token: ${{ secrets.PROJECT_TOKEN }}
When using a GitHub App (recommended):
name: Project Sync
on:
issues:
types: [opened, closed, reopened]
pull_request:
types: [opened, closed, ready_for_review, review_requested]
permissions:
contents: read
jobs:
sync:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Generate token
id: token
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: '<owner>'
- name: Sync project status
uses: Fandhe-AI/actions/project-sync@latest
with:
project-number: '<number>'
project-owner: '<owner>'
token: ${{ steps.token.outputs.token }}
When using custom Status option names:
If the Status option names differ from the defaults (Todo / In Progress / In Review / Done), specify them via inputs:
- name: Sync project status
uses: Fandhe-AI/actions/project-sync@latest
with:
project-number: '<number>'
project-owner: '<owner>'
token: ${{ secrets.PROJECT_TOKEN }}
status-todo: 'Backlog'
status-in-progress: 'In Progress'
status-in-review: 'In Review'
status-done: 'Completed'
Step A-4: Confirm Status Mapping
Default mappings for the generated workflow:
| Event | Action | Status |
|---|---|---|
| Issue | opened | Todo |
| Issue | closed | Done |
| Issue | reopened | Todo |
| PR | opened | In Progress |
| PR | ready_for_review | In Review |
| PR | review_requested | In Review |
| PR | closed (merged) | Done |
| PR | closed (not merged) | Todo |
Customize mapping rules based on user requirements.
Step A-5: Write the Workflow File
mkdir -p .github/workflows
# Save workflow contents to .github/workflows/project-sync.yml
Guide the user to commit and push the newly created workflow file.
Mode B: Manual Batch Correction
Compare current project item states against actual Issue/PR states and batch-correct any discrepancies. Useful for initial alignment after setting up auto-sync or applying manual changes.
Step B-1: Fetch Project Items
gh project item-list <number> \
--owner <owner> \
--format json \
--limit 999
Step B-2: Check Current Issue/PR States
Check current states for Issue/PR items:
gh issue view <issue-url> --json state,labels,assignees
gh pr view <pr-url> --json state,isDraft,reviewRequests,merged
Step B-3: Detect Discrepancies
Detect the following mismatch patterns:
- Issue is closed but Project Status is not Done → Update to Done
- Issue is open but Project Status is Done → Update to Todo
- PR is merged but Status is not Done → Update to Done
- PR has review requests but Status is not In Review → Update to In Review
Step B-4: Detect Unadded Repository Issues/PRs
gh issue list --state open --json number,url,title --limit 999
gh pr list --state open --json number,url,title --limit 999
Compare against existing project item URLs to identify items not yet added to the project.
Step B-5: Confirm Sync Actions with User
Display detection results:
## Planned Sync Operations
### Status Updates (N items)
- #42: Social Login — Status: In Progress → Done (Issue closed)
- #45: Bug Fix — Status: Done → Todo (Issue reopened)
- #50: Refactoring PR — Status: In Progress → In Review (Review requested)
### New Additions (M items)
- #55: Feature Request (Issue)
- #56: Documentation Update PR
Proceed with execution?
Step B-6: Execute Synchronization
# Get field metadata
gh project field-list <number> --owner <owner> --format json
# Update status
gh project item-edit \
--id <item-id> \
--field-id <status-field-id> \
--project-id <project-id> \
--single-select-option-id <option-id>
# Add new item
gh project item-add <number> \
--owner <owner> \
--url <issue-or-pr-url> \
--format json
Step B-7: Report Synchronization Results
| Operation | Count |
|---|---|
| Status Updates | N |
| New Additions | M |
| Unchanged | K |
Important Considerations
- Authentication: Accessing the Projects API from GitHub Actions requires privileges beyond
GITHUB_TOKEN. A PAT or GitHub App token is required. - PAT Expiration: Fine-grained PATs expire after a maximum of 1 year. Regular rotation is recommended.
- Coexistence with Built-in Workflows: If built-in workflows (closed→Done, merged→Done) are enabled via
project-init, events will fire twice alongside Actions workflows; however, because they write the same state, this causes no functional harm. - PR Lifecycle: Built-in workflows only support closed/merged states. Transitions like opened→In Progress and review_requested→In Review can only be automated via Actions.
- Private Repositories: Organization settings under Settings → Actions → General must allow action sharing from private repositories.
- Always obtain explicit user confirmation before applying changes in manual correction mode.
- DraftIssue items are excluded from synchronization (as no real underlying Issue exists).
- Requires active network connectivity (primarily via API; see the "Execution in Sandbox Environments" section below).
- Third-party actions must be pinned to commit SHAs: Do not generate floating references like
@mainor@vN. This avoids supply chain risks where unverified upstream tag or branch changes propagate automatically (verify diff patches before updating SHAs).Fandhe-AI/actions/*(internal actions) use@latestper organizational policy. - Explicitly declare minimal permissions: Declare
contents: readat the workflow level. Sync execution relies on permissions granted toPROJECT_TOKENor the GitHub App token, so no extra permissions are needed forGITHUB_TOKEN.
Verification
After completing Mode A: Confirm that .github/workflows/project-sync.yml exists and contains valid YAML syntax. In addition, verify the following:
- Confirm reference conventions on
uses:lines (Fandhe-AI/actions/*must use@latest, while all third-party actions must be pinned to 40-character hexadecimal commit SHAs; actively verify that third-party entries contain no floating references such as@main,@v2.2.2,@master, or branch names):
Ensuref=.github/workflows/project-sync.yml total=$(grep -c 'uses:' "$f") fandhe_total=$(grep -cE 'uses:\s*Fandhe-AI/actions/' "$f") fandhe_ok=$(grep -cE 'uses:\s*Fandhe-AI/actions/[^@[:space:]]+@latest([[:space:]]|#|$)' "$f") other_total=$((total - fandhe_total)) other_pinned=$(grep -E 'uses:' "$f" | grep -vE 'Fandhe-AI/actions/' \ | grep -cE 'uses:\s*[^@[:space:]]+@[0-9a-f]{40}([[:space:]]|#|$)' || true) if [ "$total" -eq 0 ]; then echo "NG: No uses: lines found to verify (workflow generation may have failed)" >&2 exit 1 elif [ "$fandhe_total" -eq "$fandhe_ok" ] && [ "$other_total" -eq "$other_pinned" ]; then echo OK else echo "NG: Invalid reference style in uses: lines (fandhe_total=${fandhe_total}, fandhe_ok=${fandhe_ok}, other_total=${other_total}, other_pinned=${other_pinned})" >&2 exit 1 fiOKis printed (at least 1uses:line exists, allFandhe-AI/actions/*lines use@latest, and all remaining lines use 40-character commit SHAs). IfNG:is output, review the generated workflow contents. - Confirm explicit
permissions:grep -c 'permissions:' .github/workflows/project-sync.ymlmust return 1 or greater. - Confirm
timeout-minutesis set on thesyncjob:grep -n 'timeout-minutes' .github/workflows/project-sync.ymlmust match at least 1 line (omission violates CI workflow guidelines, P1).
Setup is complete when the initial workflow trigger is confirmed in GitHub Actions execution history after committing and pushing.
After completing Mode B: Ensure the result table in Step B-7 shows "Unchanged: 0 or more". Verify the final state with:
gh project item-list <number> --owner <owner> --format json --limit 999
Execution in Sandbox Environments
This skill requires network operations against GitHub (committing/pushing sync workflows, executing batch corrections via gh project item-edit, etc.). Run relevant commands by disabling the sandbox per command execution. This skill cannot execute in environments where network restrictions cannot be bypassed.





