mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
CI_CANCEL_IN_PROGRESS gated whether a new run cancels the one before it, and it had to be remembered per repository: unset upstream meant cancel, set to false meant do not, and a fork inherited neither. Cancellation now follows the ref. Every branch but main supersedes its own runs; main never does, because a half-finished pipeline on the default branch is worse than a queued one. call-orchestrator.yml compares github.ref rather than github.ref_name: a called workflow inherits the caller's ref, which is refs/pull/<n>/merge for a pull_request caller. The manual entry workflow keeps overriding the rule through force_cancel_in_progress. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
187 lines
5.1 KiB
YAML
187 lines
5.1 KiB
YAML
name: "📤 Push"
|
|
|
|
concurrency:
|
|
group: global-ci-${{ github.repository }}-${{ github.ref_name }}
|
|
cancel-in-progress: ${{ github.ref_name != 'main' }}
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- "feature/**"
|
|
- "hotfix/**"
|
|
- "fix/**"
|
|
- "update/**"
|
|
- "chore/**"
|
|
- "alert-autofix-*"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
sync-main:
|
|
name: 🔄 Sync main
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: ⬇️ Checkout repository
|
|
uses: actions/checkout@v7.0.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: 🔄 Sync main from source repository
|
|
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: ./scripts/github/sync/main_from_repository.sh
|
|
|
|
run-policy:
|
|
name: 🧭 Decide CI policy
|
|
needs: sync-main
|
|
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
|
|
run: |
|
|
set -euo pipefail
|
|
git fetch origin 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 }}
|
|
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
|