Skip to content

chore: allow specifying database_name #3

chore: allow specifying database_name

chore: allow specifying database_name #3

name: Docker image build
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [main, develop]
# Publish semver tags as releases.
tags: ["v*.*.*"]
pull_request:
branches: [develop]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
strategy:
fail-fast: true
matrix:
type:
- linux-amd64
- linux-arm64
include:
- type: linux-amd64
docker-platform: linux/amd64
runner: ubuntu-22.04
- type: linux-arm64
docker-platform: linux/arm64
runner: arc-runner-aylamusica
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login in registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@a64d0487d7069df33b279515d35d60fa80e2ea62
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=unstable,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287
- name: Build and push by digest
id: build
uses: docker/build-push-action@090ca155fc9b214cbcac536c450455a0e96f52c6
with:
context: .
platforms: ${{ matrix.docker-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' }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.type }}-digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
needs:
- build
steps:
- name: Create digests directory
run: mkdir -p /tmp/digests
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@a64d0487d7069df33b279515d35d60fa80e2ea62
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=unstable,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
- name: Login in registry ${{ env.REGISTRY }}
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- 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") \
$(find . -type f -printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%f ')
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}