From 8af7e687c153422f64e1e6664c03b662fd6d6f3f Mon Sep 17 00:00:00 2001 From: Tom Ward Date: Mon, 25 Sep 2023 16:11:44 +0100 Subject: [PATCH] feat: add GHA workflow to keep track of the Ubuntu image SHA * This is to workaround the 3mo timeout for GHA scheduled actions on repos with no new commits, by automatically creating new commits. --- .github/workflows/update-ubuntu-sha.yaml | 33 ++++++++++++++++++++++++ Justfile | 10 +++++++ ubuntu:20.04.sha | 1 + ubuntu:22.04.sha | 1 + 4 files changed, 45 insertions(+) create mode 100644 .github/workflows/update-ubuntu-sha.yaml create mode 100644 ubuntu:20.04.sha create mode 100644 ubuntu:22.04.sha diff --git a/.github/workflows/update-ubuntu-sha.yaml b/.github/workflows/update-ubuntu-sha.yaml new file mode 100644 index 0000000..f7d9aef --- /dev/null +++ b/.github/workflows/update-ubuntu-sha.yaml @@ -0,0 +1,33 @@ +name: Update SHA of latest ubuntu images +# This is to workaround the 3mo timeout for GHA scheduled actions on repos with +# no new commits, by automatically creating new commits. +on: + schedule: + # check for a new ubuntu image every week at 04:17am on mondays + - cron: "17 04 * * 1" + # let us manually trigger a build + workflow_dispatch: +env: + BASE_IMAGE_NAME: base-docker + ACTION_IMAGE_NAME: base-action +jobs: +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d + - name: update SHAs + run: just update-docker-shas + - name: Commit file + run: | + git status + git add *.sha + if git diff-index --quiet HEAD; then + exit + fi + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -m "Update base image SHA files" + git push origin diff --git a/Justfile b/Justfile index dd051bd..a03a4d5 100644 --- a/Justfile +++ b/Justfile @@ -24,3 +24,13 @@ test: build docker run $RUN_ARGS --rm -v {{justfile_directory()}}:/tests -w /tests $ACTION_IMAGE_NAME:20.04 ./tests.sh docker run $RUN_ARGS --rm -v {{justfile_directory()}}:/tests -w /tests $ACTION_IMAGE_NAME:22.04 ./tests.sh ./check.sh + +# Update the files tracking the SHAs of ubuntu docker image +update-docker-shas: + @just _update-sha "ubuntu:20.04" + @just _update-sha "ubuntu:22.04" + +_update-sha os: + echo {{ os }} + docker image pull {{ os }} + docker inspect --format='{{{{index .RepoDigests 0}}' {{ os }} > {{ os }}.sha diff --git a/ubuntu:20.04.sha b/ubuntu:20.04.sha new file mode 100644 index 0000000..7563a52 --- /dev/null +++ b/ubuntu:20.04.sha @@ -0,0 +1 @@ +ubuntu@sha256:33a5cc25d22c45900796a1aca487ad7a7cb09f09ea00b779e3b2026b4fc2faba diff --git a/ubuntu:22.04.sha b/ubuntu:22.04.sha new file mode 100644 index 0000000..e052622 --- /dev/null +++ b/ubuntu:22.04.sha @@ -0,0 +1 @@ +ubuntu@sha256:aabed3296a3d45cede1dc866a24476c4d7e093aa806263c27ddaadbdce3c1054