Files
piik/.github/workflows/atomgit-mirror.yml
T

98 lines
3.6 KiB
YAML

name: AtomGit mirror
on:
schedule:
- cron: '17 */3 * * *'
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
workflow_dispatch:
inputs:
run_id:
description: Original CI run (optional; otherwise find the current published source)
required: false
type: string
permissions:
contents: read
actions: read
concurrency:
group: atomgit-mirror
cancel-in-progress: false
queue: max
jobs:
mirror:
if: >-
github.repository == 'TNTcraftHIM/Piik' && github.ref == 'refs/heads/main' &&
(github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ||
(github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'))
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
# Execute trusted main tooling; upstream artifacts are data, never code.
- uses: actions/checkout@v6
with:
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
/scripts/
/package.json
/package-lock.json
/.node-version
- uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- name: Check mirror readiness without build dependencies
id: readiness
run: node scripts/release-mirror-ready.mjs
env:
GH_TOKEN: ${{ github.token }}
- run: npm ci --ignore-scripts
if: steps.readiness.outputs.status == 'ready'
- name: Resolve the published source
id: source
if: steps.readiness.outputs.status == 'ready'
run: node scripts/release-mirror-source.mjs "$PIIK_SOURCE_RUN_ID"
env:
GH_TOKEN: ${{ github.token }}
PIIK_SOURCE_RUN_ID: ${{ inputs.run_id }}
- name: Download original Server artifacts
if: steps.source.outputs.mirror == 'true'
uses: actions/download-artifact@v8
with:
github-token: ${{ github.token }}
run-id: ${{ steps.source.outputs.run_id }}
pattern: piik-server*-${{ steps.source.outputs.revision }}
path: ${{ runner.temp }}/mirror-release
merge-multiple: true
- name: Download original App artifacts
if: steps.source.outputs.mirror == 'true'
uses: actions/download-artifact@v8
with:
github-token: ${{ github.token }}
run-id: ${{ steps.source.outputs.run_id }}
pattern: piik-app-*-${{ steps.source.outputs.revision }}
path: ${{ runner.temp }}/mirror-release
merge-multiple: true
- name: Mirror and verify original packages
if: steps.source.outputs.mirror == 'true'
run: >-
node scripts/mirror-release.mjs
"$RUNNER_TEMP/mirror-release" "$PIIK_RELEASE_VERSION" "$PIIK_RELEASE_REVISION"
env:
GH_TOKEN: ${{ github.token }}
ATOMGIT_TOKEN: ${{ secrets.ATOMGIT_TOKEN }}
PIIK_RELEASE_VERSION: ${{ steps.source.outputs.version }}
PIIK_RELEASE_REVISION: ${{ steps.source.outputs.revision }}
- name: Explain recovery
if: failure() && steps.source.outputs.mirror == 'true'
run: |
printf 'Mirror failed; the scheduled check will retry from original CI run %s. GitHub publication and Website are independent. If artifacts expired, recover the retained original build output; do not rebuild this version. See docs/operations/github.md.\n' "$PIIK_SOURCE_RUN_ID" >> "$GITHUB_STEP_SUMMARY"
env:
PIIK_SOURCE_RUN_ID: ${{ steps.source.outputs.run_id }}