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
8 changes: 8 additions & 0 deletions .github/workflows/update-deb-package-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions knife
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading