@theholocron/cli 2.0.0-alpha.13 → 2.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.mjs +35 -11
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1085,6 +1085,13 @@ on: # yamllint disable-line rule:truthy
1085
1085
  type: boolean
1086
1086
  required: false
1087
1087
  default: true
1088
+ secrets:
1089
+ SYNC_TOKEN:
1090
+ description: >
1091
+ Optional PAT with Contents write access. Required when the default
1092
+ branch is protected by a ruleset — github.token cannot push through
1093
+ rulesets, but a PAT with admin bypass can. Falls back to github.token.
1094
+ required: false
1088
1095
 
1089
1096
  jobs:
1090
1097
  release:
@@ -1124,7 +1131,11 @@ jobs:
1124
1131
  - run: npx semantic-release
1125
1132
  name: Release
1126
1133
  env:
1127
- GITHUB_TOKEN: \${{ github.token }}
1134
+ # Prefer SYNC_TOKEN (a PAT with Contents write) when available —
1135
+ # the built-in github.token cannot push to protected default branches
1136
+ # because rulesets block non-PAT pushes. Falls back to github.token
1137
+ # for repos without branch protection.
1138
+ GITHUB_TOKEN: \${{ secrets.SYNC_TOKEN || github.token }}
1128
1139
  NPM_CONFIG_PROVENANCE: true
1129
1140
  `,
1130
1141
  review: `\
@@ -1361,8 +1372,10 @@ name: Sync GitHub Templates
1361
1372
  # template source files change on main or alpha.
1362
1373
  #
1363
1374
  # Secrets required:
1364
- # SYNC_TOKEN — fine-grained PAT or GitHub App token with Contents write
1365
- # access to the primary and secondary repos.
1375
+ # SYNC_TOKEN — fine-grained PAT (resource owner: org) with:
1376
+ # Contents: Read and write (git trees, blobs, refs)
1377
+ # Pull requests: Read and write (open sync PR)
1378
+ # Workflows: Read and write (write .github/workflows/*.yml)
1366
1379
 
1367
1380
  on: # yamllint disable-line rule:truthy
1368
1381
  workflow_call:
@@ -1982,14 +1995,25 @@ async function runSyncGithub(input) {
1982
1995
  };
1983
1996
  }
1984
1997
  const { sha: newCommitSha } = await newCommitRes.json();
1985
- const refUpdateRes = createPr && branch ? await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs`, {
1986
- method: "POST",
1987
- headers,
1988
- body: JSON.stringify({
1989
- ref: `refs/heads/${branch}`,
1990
- sha: newCommitSha
1991
- })
1992
- }) : await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs/heads/${targetBranch}`, {
1998
+ let refUpdateRes;
1999
+ if (createPr && branch) {
2000
+ refUpdateRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs`, {
2001
+ method: "POST",
2002
+ headers,
2003
+ body: JSON.stringify({
2004
+ ref: `refs/heads/${branch}`,
2005
+ sha: newCommitSha
2006
+ })
2007
+ });
2008
+ if (refUpdateRes.status === 422) refUpdateRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs/heads/${branch}`, {
2009
+ method: "PATCH",
2010
+ headers,
2011
+ body: JSON.stringify({
2012
+ sha: newCommitSha,
2013
+ force: true
2014
+ })
2015
+ });
2016
+ } else refUpdateRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs/heads/${targetBranch}`, {
1993
2017
  method: "PATCH",
1994
2018
  headers,
1995
2019
  body: JSON.stringify({ sha: newCommitSha })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/cli",
3
- "version": "2.0.0-alpha.13",
3
+ "version": "2.0.0-alpha.15",
4
4
  "description": "The Holocron CLI — a pluggable, capability-based orchestrator for spinning up and operating software projects.",
5
5
  "homepage": "https://github.com/theholocron/holocron/tree/main/packages/cli#readme",
6
6
  "bugs": "https://github.com/theholocron/holocron/issues",