You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eee9f81
Browse filesBrowse the repository at this point in the historyBrowse files
intentionally wins in Status even with a merged PR (Todo + 已合入待发布); the
21
-
fields represent acceptance and delivery separately.
22
-
- Associate same-repository issues using closing references or standalone
23
-
`Ref(s)`, `Fix(es/ed)`, `Close(d)`, or `Resolve(s/d)` lines. Incidental mentions,
24
-
code fences, and cross-repository references do not establish a link. A reference
25
-
line containing `Fixes #12, and see #99 for context` links both same-repo issues;
26
-
keep unrelated numbers off reference lines to avoid unintended associations.
27
-
- Delivery requires every associated implementation PR to be merged, every merge
28
-
commit to be reachable from the trusted default branch, and every such commit
29
-
to be contained in the earliest published stable release. Drafts/prereleases do
30
-
not count. Populate PR links and actual release tag/URL, never guess a version.
31
-
- Issue/PR lifecycle events read only their subject and bounded linked issues/PRs,
32
-
including old/new body references and previously stored implementation links.
33
-
Fork-origin PR events are skipped to avoid spending an Actions run per fork event;
34
-
the scheduled reconciliation still observes their final repository-visible state.
35
-
They do not scan repository Issues, PRs, Project items, or releases. Six-hour
36
-
scheduled and manual runs do full reconciliation; changes discovered only by
37
-
broad push/release scans wait until the next scheduled or manual run.
38
-
- Full scans include open issues/all PRs, tracked and linked closed issues, and
39
-
all items closed on or after Project creation. This durable boundary recovers
40
-
replaced/failed events without unrelated older closed history. For an older
41
-
Project, preview catch-up before writes. Skip archived items and draft issues.
42
-
- Release version verification runs only during full scans. Event runs defer it to
43
-
the next full scan, while preserving an existing published result when its
44
-
implementation links are unchanged.
45
-
- Validate the Project schema/options and calculate all changes before writing;
46
-
skip unchanged values and clear stale text. Paginate every GraphQL connection,
47
-
reject stalled cursors, and serialize runs. Apply mode prints the plan first;
48
-
on failure it reports confirmed, outcome-unknown and unattempted mutation counts,
49
-
with affected item/field, so partial writes can be reconciled. Apply uses four
50
-
workers across distinct Project items; mutations within each item stay ordered.
51
-
This is bounded concurrency, not a guarantee against GitHub rate limits.
52
-
The synchronization job has a 120-minute total execution budget, including
53
-
checkout, scanning and writes; advancing to another step does not reset it.
54
-
- Full scans log phase/page and candidate progress to the Actions log. Stable
55
-
release membership is determined with one `git tag --contains` graph walk per
56
-
distinct merge commit instead of one `git merge-base` process per commit/tag
57
-
pair; missing fetched tags fail closed.
58
-
- Local microbenchmark against the full checkout: 237 version tags and 20 sampled
59
-
tag commits (version order used as a proxy for publication order). Pairwise
60
-
`merge-base` checks ran 2,110 processes in 31.67 s; `tag --contains` ran 20 in
61
-
0.35 s (90x on this sample). This measures Git ancestry only, not GraphQL or
62
-
full-workflow wall time.
63
-
- Privileged jobs run trusted default-branch code only, use full Git history/tags,
64
-
and never execute PR code. PR tests use no Project secret.
65
-
66
-
Run offline tests and checks:
3
+
The `Sync GitHub Project` workflow updates Project status and release tracking from repository issues and pull requests. It does not edit or delete source issues or PRs. Manual dispatch and local runs preview changes by default.
67
4
68
-
```sh
69
-
python -I tests/test_sync_github_project.py -v
70
-
python -I tests/test_project_delivery.py -v
71
-
python -I tests/test_project_events.py -v
72
-
uv run ruff format --check scripts/sync_github_project.py tests/test_sync_github_project.py tests/test_project_delivery.py
73
-
uv run ruff check scripts/sync_github_project.py
74
-
```
5
+
## Configure the integration
75
6
76
-
## Configuration
7
+
1. Create these fields in the destination Projects v2 project:
|`ASTRBOT_PROJECT_STATUS_MAP`| Optional JSON object mapping remaining canonical Status values to existing option labels |
15
+
2. Under **Settings → Environments**, create `project-sync`. Choose **Selected branches and tags** and allow exactly the default branch (`master`), using a branch rule. Do not allow tags or wildcard branches. Use required reviewers where available and restrict changes to these rules. If environment protection is unavailable, leave synchronization disabled.
16
+
3. After configuring protection, add the **environment secret**`ASTRBOT_PROJECT_ENV_TOKEN` with Project write and repository Issue/PR read access. For example, use a classic personal access token with `project` scope from an account that can edit the Project, subject to organization SSO and token policies. Do not store it as a repository or organization secret; remove any old `ASTRBOT_PROJECT_TOKEN` secret at those scopes.
17
+
4. Set the repository Actions variables below. Setting `ASTRBOT_PROJECT_ID` enables the workflow.
86
18
87
-
Example map when an existing Project uses translated Status labels:
19
+
| Variable | Value |
20
+
| --- | --- |
21
+
|`ASTRBOT_PROJECT_ID`| Destination Project node ID (`PVT_...`) |
22
+
|`ASTRBOT_PROJECT_STATUS_OPEN`| Open-state label; defaults to `Todo`|
23
+
|`ASTRBOT_PROJECT_STATUS_DONE`| Closed/merged-state label; defaults to `Done`|
24
+
|`ASTRBOT_PROJECT_STATUS_MAP`| Optional JSON map from other canonical Status values to existing labels |
Merge to the default branch, configure the fields and secret, then preview with
138
-
manual dispatch before selecting `apply`. Verify an Issue→PR→merge→stable release
139
-
path plus a fork PR. A mutation can partially apply; rerunning or waiting for the
140
-
next schedule reconciles current state. Remove `ASTRBOT_PROJECT_ID` to disable.
41
+
The workflow maps the environment secret to the script's `ASTRBOT_PROJECT_TOKEN` process variable. Local runs use that variable too. The repository `GITHUB_TOKEN` is not used for Project writes.
42
+
43
+
## Preview and apply
44
+
45
+
After merging the workflow to the default branch, run it manually on that branch with `apply` unchecked. Review the plan, then run with `apply` selected. Verify an issue → PR → merge → stable release sequence and a fork PR.
46
+
47
+
Before using a live credential, verify that dispatch from a non-default branch is denied. Environment protection checks the triggering workflow ref, not the checked-out ref. Do not add branch exceptions for rejected PR-target events; the next scheduled or default-branch manual run reconciles them.
48
+
49
+
Remove `ASTRBOT_PROJECT_ID` to disable synchronization. Coordinate any native Project automation that writes the same fields.
50
+
51
+
## Synchronization rules
141
52
142
-
## Boundaries
53
+
| Situation | Result |
54
+
| --- | --- |
55
+
| Open issue without an implementation |`Todo`; preserve a manually selected nonterminal status |
56
+
| Linked active PR |`In progress`|
57
+
| Linked merged PR |`Needs verification`; merging does not imply acceptance |
58
+
| Closed issue |`Done`, or `Cancelled` for `NOT_PLANNED`|
59
+
| Closed unmerged PR |`Closed unmerged`|
60
+
| Reopened terminal item |`Todo`|
61
+
62
+
For open issues, `status:needs-info` and `status:needs-verification` override inferred progress. `needs-info` takes precedence even with a merged PR; acceptance status and delivery progress are separate fields.
63
+
64
+
Issues are linked through closing references or standalone `Ref(s)`, `Fix(es/ed)`, `Close(d)`, or `Resolve(s/d)` lines. Keep unrelated issue numbers off those lines: `Fixes #12, and see #99 for context` links both. Incidental mentions, code fences, and cross-repository references do not establish links.
65
+
66
+
A delivery is released only when all associated implementation PRs are merged, their commits are reachable from the default branch, and a published stable release contains all those commits. The earliest qualifying release supplies the version and URL; drafts and prereleases do not count.
67
+
68
+
## Schedule and recovery
69
+
70
+
- Issue and same-repository PR events reconcile the changed item and its linked items. Fork PR events are skipped; full scans include their repository-visible state.
71
+
- Scheduled runs every six hours and manual runs perform full reconciliation, including release verification. Event runs preserve an existing release result while implementation links are unchanged.
72
+
- Full scans include open issues, all PRs, tracked or linked closed issues, and items closed since Project creation. Archived items and draft issues are skipped. Preview catch-up before applying to an older Project.
73
+
- Each run validates the schema and prints its plan before writing. Runs are serialized and have a 120-minute total timeout. API errors or missing fetched tags stop the run.
74
+
- A failed apply reports confirmed, outcome-unknown, and unattempted writes. Rerun or wait for the next scheduled scan to reconcile partial changes. The Actions log shows scan progress.
75
+
76
+
Privileged runs use default-branch code and full Git history and tags. Never check out PR code or expose the Project token in PR test jobs. Keep Actions pinned to immutable commit SHAs when updating them.
143
77
144
-
- Always: pass GraphQL variables separately, paginate connections, fail on API
145
-
errors, use timeouts, preview before manual writes, test without credentials.
changing automatic Status rules, creating credentials or a Project.
148
-
- Never: commit secrets, check out PR head code in the privileged workflow,
149
-
modify issue/PR state, delete project items, commit or push without permission.
78
+
## Local validation
150
79
151
-
Unrelated items closed before Project creation are intentionally not imported. Coordinate any
152
-
native Project automation that writes these same fields. GitHub Actions and live
153
-
API validation require maintainer configuration after merge.
80
+
Run the offline checks without credentials:
154
81
155
-
## API reference
82
+
```sh
83
+
python -I tests/test_sync_github_project.py -v
84
+
python -I tests/test_project_delivery.py -v
85
+
python -I tests/test_project_events.py -v
86
+
uv run ruff format --check scripts/sync_github_project.py tests/test_sync_github_project.py tests/test_project_delivery.py tests/test_project_events.py
87
+
uv run ruff check scripts/sync_github_project.py
88
+
```
156
89
157
-
GitHub's official "Using the API to manage Projects" documentation describes
158
-
ProjectV2 field lookup, `addProjectV2ItemById` (including existing-item reuse),
See GitHub's [Projects API guide](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects) for field lookup and item mutations.
0 commit comments