mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
The gate flagged six of my own changes. INFINITO_ANSIBLE_COLLECTIONS_SOURCE reached default.env without a handler, so the generator dropped it silently; ansible.sh then carried a shell-side default for the same key, a second source that drifts. Both are now one declaration, read as required, so a missing key fails loudly instead of falling back. File reads route through the session cache except where the same run rewrites the file, which is the documented opt-out and now says so per call. The updater reads yaml through utils.cache.yaml rather than calling safe_load itself. restore_collection_history.sh was committed without its executable bit, and the new workflow's name was 31 characters where the dispatch menu truncates at 25; the explanatory wording lives in run-name instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
39 lines
959 B
Bash
Executable File
39 lines
959 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
: "${GH_TOKEN:?Missing GH_TOKEN}"
|
|
: "${GITHUB_REPOSITORY:?Missing GITHUB_REPOSITORY}"
|
|
: "${HISTORY_PATH:?Missing HISTORY_PATH}"
|
|
: "${HISTORY_WORKFLOW:?Missing HISTORY_WORKFLOW}"
|
|
|
|
ARTIFACT_NAME="${ARTIFACT_NAME:-collection-source-history}"
|
|
|
|
mkdir -p "$(dirname "${HISTORY_PATH}")"
|
|
|
|
run_id="$(
|
|
gh run list \
|
|
--repo "${GITHUB_REPOSITORY}" \
|
|
--workflow "${HISTORY_WORKFLOW}" \
|
|
--status success \
|
|
--limit 1 \
|
|
--json databaseId \
|
|
--jq '.[0].databaseId // empty'
|
|
)"
|
|
|
|
if [[ -z "${run_id}" ]]; then
|
|
echo "No previous successful run; starting a fresh history."
|
|
exit 0
|
|
fi
|
|
|
|
tmp_dir="$(mktemp -d)"
|
|
if ! gh run download "${run_id}" \
|
|
--repo "${GITHUB_REPOSITORY}" \
|
|
--name "${ARTIFACT_NAME}" \
|
|
--dir "${tmp_dir}"; then
|
|
echo "Run ${run_id} carries no ${ARTIFACT_NAME}; starting a fresh history."
|
|
exit 0
|
|
fi
|
|
|
|
cp "${tmp_dir}/$(basename "${HISTORY_PATH}")" "${HISTORY_PATH}"
|
|
echo "Restored history from run ${run_id}."
|