Skip to content

Update all non-major dependencies (#265) #172

Update all non-major dependencies (#265)

Update all non-major dependencies (#265) #172

Workflow file for this run

name: CI Pipeline
# This workflow build and run tests inside the dev container
# only after the pull request is merged to main branch.
# Once tests are successful it builds and pushes the
# smaller size production image with multiarch suppport.
on:
push:
branches: [ "main" ]
####### Uncomment this to test the CI pipeline in a PR
####### You'll also need to comment the rules containing {{branch}}
####### in the `Extract Docker metadata` step
# pull_request:
# branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
REGISTRY_PATH: ${{ github.repository }}
TEST_TAG: user/app:test
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# This might be unnecessary as tests are not
# multiplatform
- name: Setup Docker buildx
uses: docker/[email protected]
# Build but don't push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build test image
id: build-test
uses: docker/[email protected]
with:
context: .
load: true
target: dev
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
# This is a barrier check to make sure we push a functional
# docker image, we can avoid linting
- name: Run tests in the test image
run: |
docker run --rm ${{ env.TEST_TAG }} make ci-test
build:
runs-on: ubuntu-latest
needs: test
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:
matrix:
docker_target:
- migrations
- http
- socketio
- dramatiq
steps:
# GitHub gives only repository complete in <owner>/<repo> format.
# Need some manual sheanigans
# Set IMAGE_NAME so we can push to <owner>/<repo>/<image>
- name: Set ENV variables
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Install the cosign tool
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/[email protected]
- name: Setup Docker buildx
uses: docker/[email protected]
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/[email protected]
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/[email protected]
with:
# list of Docker images to use as base name for tags
# <registry/<owner>/<repo_name>/<repo_name>-<target>
images: |
${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-${{ matrix.docker_target }}
# generate Docker tags based on the following events/attributes
tags: |
type=sha
type=raw,value={{branch}}-latest
type=raw,value={{branch}}-{{date 'YYYYMMDDHHmmss'}}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push production image
id: build-and-push
uses: docker/[email protected]
with:
context: .
target: ${{ matrix.docker_target }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
#TODO: Implement signature using generated key: https://docs.sigstore.dev/signing/quickstart/#signing-with-a-generated-key
# 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 using GitHub OIDC Token
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.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}