Files
computer-playbook/.github/workflows/entry-push-latest.yml
T
kevinveenbirkenbachandClaude Opus 5 bf25eb2fc7 refactor(ci): fetch the diff baseline instead of mirroring main
The sync job force-pushed the source repository's main onto this one so that
`origin/main` would mean "upstream main" for the three consumers that diff
against it. Carrying .github/workflows/** in that push is what GitHub refuses
for an App token, and `workflows` is not a GITHUB_TOKEN permission scope, so the
job needed an app installation that may write workflow files. Run 37169357364
showed the fork has no such secret at all.

Nothing reads the pushed branch. push_ci_policy.sh, affected_roles.sh and
new_roles.sh each fetch `origin main` into their own runner's clone before
reading it, and no caller queries the branch through the API. Pointing those
fetches at the configured source repository gives the same baseline read-only:
no push, no credential, no app permission to widen.

baseline_remote.sh resolves where that baseline comes from and keeps the
normalization and the disabled-value list in one place: `origin` for the source
repository itself, for a disabled sync and for a local clone without
GITHUB_REPOSITORY, and the upstream fetch URL otherwise. The fetches now carry
an explicit `main:refs/remotes/origin/main` refspec, which a URL needs and a
remote name tolerates.

The release guard keeps fetching `origin`: it asks whether a tag commit sits on
this repository's own main, which is a different question from the diff
baseline.

Removed: the sync-main job, its `needs` edge, main_from_repository.sh and the
directory that held it.

test_diff_affected_roles.py copies only the script under test into its fixture,
so it needed the new helper too. It also inherited the full environment, and a
GITHUB_REPOSITORY present in CI would have sent the fixture's baseline fetch to
the real upstream instead of its own bare remote: three of its five cases fail
that way, and the run takes 24s instead of 0.3s because it goes to the network.
The variable is now dropped alongside BASH_ENV.

Verified by running the helper in all four contexts and affected_roles.sh from
an empty refs/remotes/origin/main in a scratch clone as the fork, as the source
repository and locally; each populated the ref and completed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-04 05:44:45 +02:00

172 lines
5.0 KiB
YAML

name: "📤 Push"
concurrency:
group: global-ci-${{ github.repository }}-${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'main' || (github.ref_name == 'main' && startsWith(github.event.head_commit.message, 'Release version ')) }}
on:
push:
branches:
- main
- "feature/**"
- "hotfix/**"
- "fix/**"
- "update/**"
- "chore/**"
- "alert-autofix-*"
permissions:
contents: read
jobs:
run-policy:
name: 🧭 Decide CI policy
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
should_run: ${{ steps.decide.outputs.should_run }}
skip_reason: ${{ steps.decide.outputs.skip_reason }}
commit_in_main: ${{ steps.decide.outputs.commit_in_main }}
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
- name: ⬇️ Fetch main
if: github.event.created == true
shell: bash
env:
CI_SYNC_MAIN_SOURCE_REPOSITORY_DEFAULT: infinito-nexus/core
CI_SYNC_MAIN_SOURCE_REPOSITORY: ${{ vars.CI_SYNC_MAIN_SOURCE_REPOSITORY }}
CI_SYNC_MAIN_SOURCE_REPOSITORY_IS_SET: ${{ contains(toJSON(vars), '"CI_SYNC_MAIN_SOURCE_REPOSITORY"') }}
run: |
set -euo pipefail
git fetch "$(./scripts/meta/resolve/baseline_remote.sh)" main:refs/remotes/origin/main --force
- name: 🤔 Decide whether CI should run for this push
id: decide
env:
GITHUB_EVENT_CREATED: ${{ github.event.created }}
CI_RUN_ON_MAIN: ${{ vars.CI_RUN_ON_MAIN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: bash scripts/meta/resolve/push_ci_policy.sh
skip-ci:
name: ⏭️ Skip CI
needs: run-policy
if: needs.run-policy.outputs.should_run != 'true'
runs-on: ubuntu-latest
steps:
- name: ⏭️ Explain skip
shell: bash
run: |
set -euo pipefail
echo "Skipping CI for commit ${GITHUB_SHA}."
echo "Reason: ${{ needs.run-policy.outputs.skip_reason }}"
detect-release:
if: needs.run-policy.outputs.should_run == 'true'
needs: run-policy
name: 🏷️ Detect release tag
runs-on: ubuntu-latest
outputs:
is_version: ${{ steps.pick.outputs.is_version }}
version_tag: ${{ steps.pick.outputs.version_tag }}
steps:
- name: ⬇️ Checkout (with tags)
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
fetch-tags: true
- id: pick
shell: bash
run: bash scripts/github/resolve/release/tag.sh
resolve-priority:
if: needs.run-policy.outputs.should_run == 'true'
name: ⭐ Resolve new-role priority
needs: run-policy
runs-on: ubuntu-latest
outputs:
priority: ${{ steps.resolve.outputs.priority }}
steps:
- name: ⬇️ Checkout (full history)
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
- id: resolve
shell: bash
run: |
set -euo pipefail
echo "priority=$(bash scripts/meta/resolve/diff/new_roles.sh)" >> "$GITHUB_OUTPUT"
ci-orchestrator:
if: needs.run-policy.outputs.should_run == 'true'
name: 🎶 Orchestrate CI
needs:
- run-policy
- detect-release
- resolve-priority
permissions:
actions: read
contents: read
packages: write
security-events: write
issues: write
uses: ./.github/workflows/call-orchestrator.yml
with:
priority: ${{ needs.resolve-priority.outputs.priority }}
chunk_gate: ${{ !(github.ref_name == 'main' && needs.detect-release.outputs.is_version == 'true') }}
secrets: inherit
release-guard:
name: "🛡️ Guard release"
if: needs.run-policy.outputs.should_run == 'true' && needs.detect-release.outputs.is_version == 'true'
needs:
- run-policy
- detect-release
- ci-orchestrator
runs-on: ubuntu-latest
outputs:
allowed: ${{ steps.guard.outputs.allowed }}
steps:
- name: ⬇️ Checkout (with full history)
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
fetch-tags: true
- name: ⬇️ Fetch main
shell: bash
run: |
set -euo pipefail
git fetch origin main:refs/remotes/origin/main --force
- name: "🛡️ Guard: tag commit must be contained in origin/main"
id: guard
shell: bash
env:
VERSION_TAG: ${{ needs.detect-release.outputs.version_tag }}
run: bash scripts/github/release/guard.sh
release-version:
name: 🚀 Release version
needs:
- run-policy
- detect-release
- release-guard
if: needs.run-policy.outputs.should_run == 'true' && needs.release-guard.outputs.allowed == 'true'
permissions:
contents: read
packages: write
uses: ./.github/workflows/call-release-version.yml
with:
tag: ${{ needs.detect-release.outputs.version_tag }}
secrets: inherit