Skip to content

build(deps): Bump the rust-dependencies group with 9 updates (#95) #41

build(deps): Bump the rust-dependencies group with 9 updates (#95)

build(deps): Bump the rust-dependencies group with 9 updates (#95) #41

---
name: Container Build and Push
on:
workflow_dispatch:
push:
branches: [main]
tags: [v*]
permissions:
contents: read
packages: write
# This is used to complete the identity challenge with sigstore/fulcio.
id-token: write
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build-push:
permissions:
contents: read
packages: write
# This is used to complete the identity challenge with sigstore/fulcio.
id-token: write
strategy:
fail-fast: false
matrix:
platform: [linux/amd64]
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Install cosign
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2
with:
cosign-release: v1.13.1
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
with:
install: true
cleanup: false
platforms: ${{ matrix.platform }}
config-inline: |
[worker.oci]
gc = true
gckeepstorage = 10_000 # 10 GB
[[worker.oci.gcpolicy]]
all = true
keepBytes = 10_000_000_000 # 10 GB
keepDuration = 7_776_000 # 90 days
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: docker_meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
# FIXME: Remove explicit `latest` tag once we start tagging releases
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=long
- name: Inject Docker Build(x|Kit) cache mounts
uses: sid-maddy/buildkit-cache-dance/inject@b85212de35ab5f2a6f5cf0efcf9ffb3806dc56e7 # v1.0.0
with:
cache-mounts: |
cargo-registry,/usr/local/cargo/registry
rust-target-release,/app/target
github-token: ${{ secrets.GITHUB_TOKEN }}
key: rust-buildkit-cache-${{ matrix.platform }}-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
restore-keys: |
rust-buildkit-cache-${{ matrix.platform }}-
- name: Build and push Docker image
id: docker_build_push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
file: Containerfile
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
- name: Extract Docker Build(x|Kit) cache mounts
uses: sid-maddy/buildkit-cache-dance/extract@b85212de35ab5f2a6f5cf0efcf9ffb3806dc56e7 # v1.0.0
with:
cache-mounts: |
cargo-registry,/usr/local/cargo/registry
rust-target-release,/app/target
github-token: ${{ secrets.GITHUB_TOKEN }}
key: rust-buildkit-cache-${{ matrix.platform }}-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
# Sign the resulting Docker image digest.
# This will only write to the public Rekor transparency log when the Docker repository is public to avoid leaking
# data. If you would like to publish transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
env:
COSIGN_EXPERIMENTAL: 'true'
shell: bash
# This step uses the identity token to provision an ephemeral certificate against the sigstore community Fulcio
# instance.
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.docker_build_push.outputs.digest }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest='${{ steps.docker_build_push.outputs.digest }}'
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
if-no-files-found: error
name: digests
path: /tmp/digests/*
retention-days: 1
merge:
needs: [build-push]
runs-on: ubuntu-22.04
steps:
- name: Download digests
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: digests
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: docker_meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
# FIXME: Remove explicit `latest` tag once we start tagging releases
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=long
- name: Create manifest list and push
shell: bash
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${DOCKER_METADATA_OUTPUT_JSON}") \
$(printf ' ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
shell: bash
run: |-
docker buildx imagetools inspect '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}'