Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/chain-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
# chain-file.sh "$GITHUB_WORKFLOW_REF": print the caller's own workflow file, the argument
# to `gh workflow run` when a run chains the next one.
#
# The ref is owner/repo/.github/workflows/<file>@<ref>, and <ref> holds slashes of its own
# (refs/heads/main), so the @ and everything after it come off before the path does.
#
# `--check` runs this file's own cases instead, so the rule and its proof stay together.
set -eu

chain_file() {
path="${1%%@*}"
printf '%s\n' "${path##*/}"
}

if [ "${1-}" = --check ]; then
[ "$(chain_file 'katoptra/dropbox/.github/workflows/sync.yml@refs/heads/main')" = sync.yml ]
[ "$(chain_file 'katoptra/ctan/.github/workflows/hourly.yml@refs/heads/josh/topic')" = hourly.yml ]
[ "$(chain_file 'o/r/.github/workflows/sync.yml@81fb6ee34abc7703087cfe4a303263febc912c6f')" = sync.yml ]
echo "chain-file: PASS"
exit 0
fi

chain_file "$1"
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
if: matrix.variant == 'rsync'
run: |
sh .github/validate-vars.sh --check
sh .github/chain-file.sh --check
sh docker/gpg-gate-check.sh
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
# Layers cached in Actions, one scope per variant; release reads the same scope, so a
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
if: success()
env:
GH_TOKEN: ${{ github.token }}
# The caller's own file name, whatever it is; workflow_ref is owner/repo/.github/workflows/<file>@<ref>.
# The caller's own file name, whatever it is, cut from GITHUB_WORKFLOW_REF by chain-file.sh.
run: |
if [ -f .run/chain ]; then
f="${GITHUB_WORKFLOW_REF##*/}"; gh workflow run "${f%%@*}" --ref "$GITHUB_REF_NAME"
gh workflow run "$(sh .lib/.github/chain-file.sh "$GITHUB_WORKFLOW_REF")" --ref "$GITHUB_REF_NAME"
echo "chained: next run queued" >> "$GITHUB_STEP_SUMMARY"
fi