Skip to content

chore: group dependencies for mix dep-deps (#95) #190

chore: group dependencies for mix dep-deps (#95)

chore: group dependencies for mix dep-deps (#95) #190

name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
#schedule:
# - cron: '16 5 * * *'
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
env:
ELIXIR_VERSION: '1.15.7'
OTP_VERSION: '26.2.1'
DEBIAN_VERSION: 'bookworm-20231009-slim'
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: amd64
- os: ubuntu-aarch64
platform: arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.3'
#- name: Setup erl flags for QEMU
# if: matrix.platform != 'amd64'
# run: |
# echo "ERL_FLAGS=+JMsingle true" >> "$GITHUB_ENV"
#- name: Set up QEMU
# if: matrix.platform != 'amd64'
# uses: docker/setup-qemu-action@v3
# with:
# platforms: ${{ matrix.platform }}
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.6.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6.10.0
with:
context: .
provenance: false
platforms: linux/${{ matrix.platform }}
build-args: |
ERL_FLAGS=${{ env.ERL_FLAGS }}
ELIXIR_VERSION=${{ env.ELIXIR_VERSION }}
OTP_VERSION=${{ env.OTP_VERSION }}
DEBIAN_VERSION=${{ env.DEBIAN_VERSION }}
annotations: ${{ steps.meta.outputs.annotations }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,oci-mediatypes=true,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
# Sign the resulting Docker image digest except on PRs.
# 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:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign --yes "${REGISTRY}/${IMAGE_NAME}@${DIGEST}"
- run: echo "${{ steps.build-and-push.outputs.digest }}" > digest-${{ matrix.platform }}.txt
- uses: actions/upload-artifact@v4
with:
name: digest-${{ matrix.platform }}
path: digest-${{ matrix.platform }}.txt
merge:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
needs:
- build
steps:
- uses: actions/download-artifact@v4
with:
path: digests
pattern: digest-*
merge-multiple: true
- name: Get digests
id: digests
run: |
{
echo 'result<<EOF'
find digests -name 'digest-*.txt' -exec cat {} \;
echo 'EOF'
} >> "$GITHUB_OUTPUT"
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.3'
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.6.1
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
#type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=edge
type=ref,event=pr
type=sha,prefix=
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
id: imagetools
uses: kphrx/docker-buildx-imagetools-action@v0.1.2
with:
annotations: ${{ steps.meta.outputs.annotations }}
sources: ${{ steps.digests.outputs.result }}
tags: ${{ steps.meta.outputs.tags }}
# Sign the resulting Docker image digest except on PRs.
# 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:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.imagetools.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes "{}@${DIGEST}"