diff --git a/.github/workflows/update-deb-package-snapshots.yml b/.github/workflows/update-deb-package-snapshots.yml index bec160db7..fd774d57a 100644 --- a/.github/workflows/update-deb-package-snapshots.yml +++ b/.github/workflows/update-deb-package-snapshots.yml @@ -5,6 +5,11 @@ on: - cron: "35 20 * * *" # allow this workflow to be manually run workflow_dispatch: + inputs: + skip_delay: + description: "Skip the 1 day buffer and take the newest snapshot (strictly newer than the current one)" + type: boolean + default: false permissions: contents: read @@ -25,6 +30,9 @@ jobs: go-version: "1.25" - name: Update snapshots + env: + # inputs.skip_delay is empty on scheduled runs, so the default 1 day buffer applies + SNAPSHOT_SKIP_DELAY: ${{ inputs.skip_delay == true }} run: ./knife github-update-snapshots - name: Set up QEMU diff --git a/knife b/knife index 51f818c81..e7e2a1ab0 100755 --- a/knife +++ b/knife @@ -66,6 +66,22 @@ function find_latest_snapshot() { # intentionally don't include complicated logic for the case where it's after the 1st and no snapshots are # available for the month (it's extremely unlikely for our updater to run into this situation unless the # snapshot serving infrastructure is acting up). + # + # Set SNAPSHOT_SKIP_DELAY=true to bypass the buffer and take the newest available snapshot (including + # today's). Callers only ever move forward, so this pulls any snapshot strictly newer than the current one. + if [[ "${SNAPSHOT_SKIP_DELAY:-false}" == "true" ]]; then + local latest="" + # check this month first, falling back to last month if nothing has been published yet + for offset in "now" "$(date +%Y-%m-01) -1 day"; do + local q=$(date -d "$offset" +"year=%Y&month=%m") + latest=$(curl -fs "https://snapshot.debian.org/archive/${type}/?$q" | grep -ohE "([0-9]+T[0-9]+Z)" | sort | tail -n1 || true) + if [[ -n "$latest" ]]; then + echo "$latest" + return + fi + done + return + fi local current="$(date -d '-1 day' +%Y-%m-%d)" local tmp=$(mktemp) local q=$(date -d "$current" +"year=%Y&month=%m")