Files
AstrBot/.github/workflows/project-sync.yml
Sha1rholder ab4ddd662d perf(ci): simplify CI and speed it up (#11226)
* CI: Simplify smoke test

* follow-up for standardizing uv setup and skip redundant syncs

* CI: Use uv for project sync workflows

Reference actions by version tag and reduce the sync timeout from 120 to
10 minutes. Drop references to the deleted delivery test and remove
workflow security assertions.
2026-11-18 22:09:02 +08:00

73 lines
2.8 KiB
YAML

name: Sync GitHub Project
on:
issues:
types: [opened, reopened, closed, labeled, unlabeled, edited]
pull_request_target:
types: [opened, reopened, closed, edited, synchronize, ready_for_review, converted_to_draft]
schedule:
- cron: '17 */6 * * *'
workflow_dispatch:
inputs:
apply:
description: 'Apply the change plan (false previews without writing)'
type: boolean
default: false
required: true
permissions:
contents: read
# Every run reconciles the whole project; serialize snapshots, not just items.
# Pending runs can be replaced; full scans recover items closed since project creation.
concurrency:
group: project-sync-${{ github.repository }}
cancel-in-progress: false
jobs:
sync:
if: >-
github.repository == 'AstrBotDevs/AstrBot' &&
vars.ASTRBOT_PROJECT_ID != '' &&
(github.event_name != 'pull_request_target' ||
github.event.pull_request.head.repo.full_name == github.repository)
# Configure this environment to allow only the default branch before adding secrets.
environment: project-sync
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Validate manual branch
if: github.event_name == 'workflow_dispatch' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
run: |
echo 'Manual sync must run from the default branch.'
exit 1
# Never check out the PR head or a PR-controlled base branch with this token.
- name: Check out trusted default branch
uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch || github.ref_name }}
persist-credentials: false
fetch-depth: 0
fetch-tags: true
sparse-checkout: scripts/sync_github_project.py
sparse-checkout-cone-mode: false
- name: Set up uv
uses: astral-sh/setup-uv@v10.3.3
- name: Synchronize current item state
env:
ASTRBOT_PROJECT_ID: ${{ vars.ASTRBOT_PROJECT_ID }}
ASTRBOT_PROJECT_STATUS_OPEN: ${{ vars.ASTRBOT_PROJECT_STATUS_OPEN }}
ASTRBOT_PROJECT_STATUS_DONE: ${{ vars.ASTRBOT_PROJECT_STATUS_DONE }}
ASTRBOT_PROJECT_STATUS_MAP: ${{ vars.ASTRBOT_PROJECT_STATUS_MAP }}
ASTRBOT_PROJECT_TOKEN: ${{ secrets.ASTRBOT_PROJECT_ENV_TOKEN }}
ASTRBOT_DEFAULT_BRANCH: ${{ github.event.repository.default_branch || github.ref_name }}
APPLY_CHANGES: ${{ github.event_name != 'workflow_dispatch' || inputs.apply }}
run: |
if [ "$APPLY_CHANGES" = 'true' ]; then
uv run --no-project python -I scripts/sync_github_project.py --apply
else
uv run --no-project python -I scripts/sync_github_project.py
fi