-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ci): auto-move Done → Released on GitHub Release publish #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
87d8941
fc7cddd
96b73ef
e79112e
6dff59f
ba902db
0854b0f
3f66cc3
e8a5189
038ae76
341b46a
cbe952c
3fa6de9
6d3cd60
290ed81
c4194a5
33a1048
989f13b
14f85fe
27d1e47
5a2bddb
5f57e8b
0edf4fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: Squad Mark Released | ||
|
|
||
| on: | ||
| release: | ||
| types: [published, released] | ||
|
|
||
| permissions: | ||
| repository-projects: write | ||
|
|
||
| env: | ||
| PROJECT_ID: PVT_kwHOA5k0b84BVFTy | ||
| STATUS_FIELD_ID: PVTSSF_lAHOA5k0b84BVFTyzhQjgPk | ||
| DONE_OPTION_ID: "98236657" | ||
| RELEASED_OPTION_ID: "8e246b27" | ||
|
|
||
| jobs: | ||
| mark-released: | ||
| # Skip pre-releases (insider builds) and drafts — only real releases move items | ||
| if: ${{ !github.event.release.prerelease && !github.event.release.draft }} | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Move Done → Released on project board | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const PROJECT_ID = process.env.PROJECT_ID; | ||
| const STATUS_FIELD_ID = process.env.STATUS_FIELD_ID; | ||
| const DONE_OPTION_ID = process.env.DONE_OPTION_ID; | ||
| const RELEASED_OPTION_ID = process.env.RELEASED_OPTION_ID; | ||
|
|
||
| let cursor = null; | ||
| let moved = 0; | ||
|
|
||
| do { | ||
| const result = await github.graphql(` | ||
| query($projectId: ID!, $cursor: String) { | ||
| node(id: $projectId) { | ||
| ... on ProjectV2 { | ||
| items(first: 100, after: $cursor) { | ||
| pageInfo { hasNextPage endCursor } | ||
| nodes { | ||
| id | ||
| fieldValues(first: 50) { | ||
| nodes { | ||
| ... on ProjectV2ItemFieldSingleSelectValue { | ||
| optionId | ||
| field { | ||
| ... on ProjectV2SingleSelectField { id } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `, { projectId: PROJECT_ID, cursor }); | ||
|
|
||
| const items = result.node.items; | ||
| cursor = items.pageInfo.hasNextPage ? items.pageInfo.endCursor : null; | ||
|
|
||
| for (const item of items.nodes) { | ||
| // Match by field ID (not name) to avoid brittleness on renames | ||
| const isDone = item.fieldValues.nodes.some( | ||
| fv => fv.field?.id === STATUS_FIELD_ID && fv.optionId === DONE_OPTION_ID | ||
| ); | ||
| if (!isDone) continue; | ||
|
|
||
| await github.graphql(` | ||
| mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) { | ||
| updateProjectV2ItemFieldValue(input: { | ||
| projectId: $projectId | ||
| itemId: $itemId | ||
| fieldId: $fieldId | ||
| value: { singleSelectOptionId: $optionId } | ||
| }) { | ||
| projectV2Item { id } | ||
| } | ||
| } | ||
| `, { | ||
| projectId: PROJECT_ID, | ||
| itemId: item.id, | ||
| fieldId: STATUS_FIELD_ID, | ||
| optionId: RELEASED_OPTION_ID, | ||
| }); | ||
|
|
||
| moved++; | ||
| core.info(`✅ Item ${item.id} → Released`); | ||
| } | ||
| } while (cursor); | ||
|
|
||
| core.notice(`🎉 Moved ${moved} item(s) from Done → Released for ${context.payload.release.tag_name}`); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,7 @@ jobs: | |
| run: dotnet build MyBlog.slnx --configuration Release --no-restore -p:TreatWarningsAsErrors=true | ||
|
|
||
| - name: Run unit tests | ||
| run: dotnet test MyBlog.slnx --configuration Release --no-build --verbosity normal | ||
| run: | | ||
| dotnet test tests/Architecture.Tests --configuration Release --no-build --verbosity normal | ||
| dotnet test tests/Web.Tests --configuration Release --no-build --verbosity normal | ||
| dotnet test tests/Web.Tests.Integration --configuration Release --no-build --verbosity normal | ||
|
Comment on lines
28
to
+32
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The per-item
updateProjectV2ItemFieldValuecall isn’t wrapped in error handling. As written, a single mutation failure (rate limit, transient network error, 403 due to project permissions, etc.) will fail the entire job mid-loop and leave subsequent Done items unmoved. Consider wrapping the mutation in a try/catch that logs a warning and continues, and optionally provide a specific hint for 403s (similar to other project-board workflows) so operators know how to remediate.