feat: restore template vars for GitHub App customization #1

Merged
jakeclaw-ai[bot] merged 4 commits from feat/restore-template-vars into main 2026-03-15 11:23:09 +00:00
8 changed files with 39 additions and 14 deletions

View File

@@ -3,5 +3,11 @@
- "src/**" - "src/**"
- "src/.*" - "src/.*"
- "src/.*/**" - "src/.*/**"
- template:
- "src/.github/workflows/release.yaml"
- template-vars:
GH_APP_ID_VAR: CHRISTMAS_ISLAND_APP_ID
GH_APP_KEY_SECRET: CHRISTMAS_ISLAND_PRIVATE_KEY
GH_APP_OWNER: christmas-island
- rename: - rename:
- "^src/(.*)$": "$1" - "^src/(.*)$": "$1"

View File

@@ -16,7 +16,7 @@ jobs:
run: | run: |
# Verify distributed files in src/ match the repo's own copies # Verify distributed files in src/ match the repo's own copies
status=0 status=0
for file in .releaserc.yaml commitlint.config.js; do for file in .releaserc.yaml commitlint.config.cjs; do
if ! diff -q "$file" "src/$file" > /dev/null 2>&1; then if ! diff -q "$file" "src/$file" > /dev/null 2>&1; then
echo "❌ $file differs from src/$file" echo "❌ $file differs from src/$file"
diff --color "$file" "src/$file" || true diff --color "$file" "src/$file" || true
@@ -25,7 +25,7 @@ jobs:
echo "✅ $file matches src/$file" echo "✅ $file matches src/$file"
fi fi
done done
for file in .github/workflows/commitlint.yml .github/workflows/release.yaml; do for file in .github/workflows/commitlint.yml; do
if ! diff -q "$file" "src/$file" > /dev/null 2>&1; then if ! diff -q "$file" "src/$file" > /dev/null 2>&1; then
echo "❌ $file differs from src/$file" echo "❌ $file differs from src/$file"
diff --color "$file" "src/$file" || true diff --color "$file" "src/$file" || true
@@ -34,6 +34,8 @@ jobs:
echo "✅ $file matches src/$file" echo "✅ $file matches src/$file"
fi fi
done done
# release.yaml intentionally differs: src/ uses template vars, top-level uses hardcoded defaults
echo "⏭️ .github/workflows/release.yaml skipped (template vars in src/)"
if [ $status -ne 0 ]; then if [ $status -ne 0 ]; then
echo "" echo ""
echo "Top-level files and src/ are out of sync." echo "Top-level files and src/ are out of sync."

View File

@@ -17,4 +17,4 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548c61b7286b4ffe7cb3d # v6 - uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6

View File

@@ -15,7 +15,7 @@ Files distributed from `src/`:
## Usage ## Usage
> **Requires common-repo ≥ 0.28.0** for source-declared filtering. > **Requires common-repo ≥ 0.28.4** for source-declared filtering and template variable overrides.
### Add to an existing `.common-repo.yaml` ### Add to an existing `.common-repo.yaml`
@@ -56,19 +56,36 @@ cr-semantic-release/
└── commitlint.config.js └── commitlint.config.js
``` ```
The top-level files and `src/` files are identical — the repo eats its own dog food. CI enforces they stay in sync. The top-level files and `src/` files are identical — the repo eats its own dog food. CI enforces they stay in sync (except `release.yaml`, which uses template variables in `src/` and hardcoded defaults at the top level).
## Prerequisites ## Prerequisites
The release workflow expects the following GitHub org-level vars and secrets: By default, the release workflow uses these GitHub org-level vars and secrets:
| Name | Type | Purpose | | Name | Type | Default | Purpose |
|---|---|---| |---|---|---|---|
| `CHRISTMAS_ISLAND_APP_ID` | Variable | GitHub App ID for generating tokens | | `CHRISTMAS_ISLAND_APP_ID` | Variable | — | GitHub App ID for generating tokens |
| `CHRISTMAS_ISLAND_PRIVATE_KEY` | Secret | GitHub App private key | | `CHRISTMAS_ISLAND_PRIVATE_KEY` | Secret | — | GitHub App private key |
These are used by `actions/create-github-app-token` to generate a token with write permissions for creating releases and pushing tags/changelogs. These are used by `actions/create-github-app-token` to generate a token with write permissions for creating releases and pushing tags/changelogs.
### Using a different GitHub App
Override the template variables in your consumer config to use your own app credentials:
```yaml
- repo:
url: https://github.com/christmas-island/cr-semantic-release
ref: v2.0.0
with:
- template-vars:
GH_APP_ID_VAR: MY_APP_ID # GitHub vars name
GH_APP_KEY_SECRET: MY_APP_KEY # GitHub secrets name
GH_APP_OWNER: my-org # App installation owner
```
This renders the workflow with `${{ vars.MY_APP_ID }}`, `${{ secrets.MY_APP_KEY }}`, and `owner: my-org`.
## Customization ## Customization
### Release workflow ### Release workflow

View File

@@ -17,4 +17,4 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548c61b7286b4ffe7cb3d # v6 - uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6

View File

@@ -32,9 +32,9 @@ jobs:
id: app-token id: app-token
uses: actions/create-github-app-token@v1 uses: actions/create-github-app-token@v1
with: with:
app-id: ${{ vars.CHRISTMAS_ISLAND_APP_ID }} app-id: ${{ vars.${GH_APP_ID_VAR:-CHRISTMAS_ISLAND_APP_ID} }}
private-key: ${{ secrets.CHRISTMAS_ISLAND_PRIVATE_KEY }} private-key: ${{ secrets.${GH_APP_KEY_SECRET:-CHRISTMAS_ISLAND_PRIVATE_KEY} }}
owner: christmas-island owner: ${GH_APP_OWNER:-christmas-island}
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with: with:
fetch-depth: 0 fetch-depth: 0