redsunlib/.github/workflows/main-docker.yml

110 lines
3.5 KiB
YAML
Raw Permalink Normal View History

name: Container build
on:
workflow_run:
workflows: ["Release Build"]
types:
- completed
env:
REGISTRY_IMAGE: quay.io/redlib/redlib
jobs:
build:
runs-on: ubuntu-latest
2023-06-01 11:47:58 +12:00
strategy:
fail-fast: false
2023-06-01 11:47:58 +12:00
matrix:
include:
- { platform: linux/amd64, target: x86_64-unknown-linux-musl }
- { platform: linux/arm64, target: aarch64-unknown-linux-musl }
- { platform: linux/arm/v7, target: armv7-unknown-linux-musleabihf }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Quay.io Container Registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
file: Dockerfile
build-args: TARGET=${{ matrix.target }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
2024-09-17 08:29:52 +12:00
uses: actions/upload-artifact@v4
with:
2024-09-17 08:36:24 +12:00
name: digests-${{ matrix.target }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4.1.7
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to Quay.io Container Registry
uses: docker/login-action@v3
with:
2023-12-27 12:25:52 +13:00
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_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") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
2023-06-01 11:47:58 +12:00
# - name: Push README to Quay.io
# uses: christian-korneck/update-container-description-action@v1
# env:
# DOCKER_APIKEY: ${{ secrets.APIKEY__QUAY_IO }}
# with:
# destination_container_repo: quay.io/redlib/redlib
# provider: quay
# readme_file: 'README.md'
2023-06-01 11:47:58 +12:00
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}