Skip to content

Update base image

Update base image #242

Workflow file for this run

name: Update base image
on:
push:
branches:
- main
paths:
- image/Dockerfile-base
- .github/workflows/base-image.yaml
schedule:
- cron: 0 1 1 * *
permissions:
contents: read
jobs:
push_image:
runs-on: ubuntu-24.04
name: Docker Images
permissions:
id-token: write
attestations: write
environment:
name: dockerhub
url: https://hub.docker.com/r/danielflook/terraform-github-actions-base/tags?name=${{ github.run_id }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Registry login
env:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: |
echo "$DOCKER_TOKEN" | docker login --username danielflook --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
- name: Base image
id: build-and-push
run: |
BASE_DIGEST=$(docker buildx imagetools inspect "debian:bookworm-slim" --format '{{json .}}' | jq -r '.manifest.digest')
sed -i "s|FROM debian:bookworm-slim|FROM debian:bookworm-slim@$BASE_DIGEST|" "image/Dockerfile-base"
docker buildx build \
--tag "danielflook/terraform-github-actions-base:$GITHUB_RUN_ID" \
--tag danielflook/terraform-github-actions-base:latest \
--platform linux/amd64,linux/arm64 \
--attest "type=provenance,mode=max,builder-id=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--annotation "index,manifest:org.opencontainers.image.created=$(date '+%Y-%m-%dT%H:%M:%S%z')" \
--annotation "index,manifest:org.opencontainers.image.source=https://github.com/${{ github.repository }}" \
--annotation "index,manifest:org.opencontainers.image.revision=${{ github.sha }}" \
--annotation "index,manifest:org.opencontainers.image.title=terraform-github-actions-base" \
--annotation "index,manifest:org.opencontainers.image.description=Base image for terraform-github-actions" \
--annotation "index:org.opencontainers.image.ref.name=docker.io/danielflook/terraform-github-actions-base:$GITHUB_RUN_ID" \
--annotation "index,manifest:builder-id=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--annotation "index,manifest:ref.tag=$GITHUB_RUN_ID" \
--annotation "index,manifest:org.opencontainers.image.base.name=docker.io/debian:bookworm-slim" \
--annotation "index,manifest:base.manifest.digest=$BASE_DIGEST" \
--file image/Dockerfile-base \
--push \
--iidfile manifest-list-digest.txt \
image
echo "digest=$(<manifest-list-digest.txt)" >> "$GITHUB_OUTPUT"
- name: Generate image attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: index.docker.io/danielflook/terraform-github-actions-base
subject-digest: ${{ steps.build-and-push.outputs.digest }}