Skip to content

chore(deps): bump docker/login-action from 4.0.0 to 4.1.0 in the github-actions group #57

chore(deps): bump docker/login-action from 4.0.0 to 4.1.0 in the github-actions group

chore(deps): bump docker/login-action from 4.0.0 to 4.1.0 in the github-actions group #57

Workflow file for this run

name: Docker
on:
push:
branches: [main]
tags: ["v*.*.*"]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-test-
- name: Run tests
run: cargo test
build-binary:
needs: test
runs-on: ubuntu-latest
container: rust:bookworm
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
rust-target: x86_64-unknown-linux-gnu
- arch: arm64
rust-target: aarch64-unknown-linux-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install cross-compilation toolchain
if: matrix.arch == 'arm64'
run: |
apt-get update
apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross
- name: Add Rust target
run: rustup target add ${{ matrix.rust-target }}
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
/usr/local/cargo/registry
/usr/local/cargo/git
target
key: cargo-build-${{ matrix.arch }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-build-${{ matrix.arch }}-
- name: Configure linker
if: matrix.arch == 'arm64'
run: |
mkdir -p .cargo
printf '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"\n' > .cargo/config.toml
- name: Build release binary
run: cargo build --release --target ${{ matrix.rust-target }}
- name: Upload binary artifact
uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.arch }}
path: target/${{ matrix.rust-target }}/release/vcontrold-mqttd
if-no-files-found: error
retention-days: 1
build-docker:
needs: build-binary
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
arch: amd64
- platform: linux/arm64
arch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download binary artifact
uses: actions/download-artifact@v8
with:
name: binary-${{ matrix.arch }}
path: .
- name: Make binary executable
run: chmod +x vcontrold-mqttd
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
if: matrix.arch == 'arm64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v4.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v7.0.0
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }}
cache-to: ${{ github.event_name != 'pull_request' && format('type=registry,ref={0}/{1}:buildcache-{2},mode=max', env.REGISTRY, env.IMAGE_NAME, matrix.arch) || '' }}
- name: Export digest
if: github.event_name != 'pull_request'
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v7
with:
name: digests-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs: build-docker
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v4.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Create manifest list and push
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: Get manifest digest
id: digest
run: |
# Get the first tag to inspect
TAG=$(echo "$DOCKER_METADATA_OUTPUT_JSON" | jq -r '.tags[0]')
# Extract just the digest hash from the inspect output
DIGEST=$(docker buildx imagetools inspect "$TAG" --format '{{json .Manifest}}' | jq -r '.digest')
echo "digest=${DIGEST}" >> $GITHUB_OUTPUT
- name: Install cosign
uses: sigstore/cosign-installer@v4.1.1
- name: Sign the published Docker image
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.digest.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}