Docker CI #186
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker CI | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 0 * * 0" | |
jobs: | |
build-oci-images: | |
runs-on: ${{ matrix.target.runner }} | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
strategy: | |
matrix: | |
target: | |
- id: weron-linux-amd64 | |
src: . | |
file: Dockerfile | |
image: ghcr.io/pojntfx/weron | |
arch: "linux/amd64,linux/arm/v7,linux/386,linux/s390x" # linux/mips64le,linux/ppc64le,linux/arm/v5 | |
runner: ubuntu-latest | |
- id: weron-linux-arm64-v8 | |
src: . | |
file: Dockerfile | |
image: ghcr.io/pojntfx/weron | |
arch: "linux/arm64/v8" | |
runner: ubicloud-standard-4-arm | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ matrix.target.image }} | |
- name: Build and push image by digest to registry | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.target.src }} | |
file: ${{ matrix.target.src }}/${{ matrix.target.file }} | |
platforms: ${{ matrix.target.arch }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ matrix.target.image }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Export digest | |
run: | | |
mkdir -p "/tmp/digests" | |
export DIGEST="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${DIGEST#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ matrix.target.id }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge-oci-images: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
needs: build-oci-images | |
strategy: | |
matrix: | |
target: | |
- idprefix: weron-linux- | |
image: ghcr.io/pojntfx/weron | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ matrix.target.image }} | |
tags: type=semver,pattern={{version}} | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-${{ matrix.target.idprefix }}* | |
merge-multiple: true | |
- name: Create pre-release manifest list and push to registry | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create --tag "${{ matrix.target.image }}:${{ github.ref_name }}" $(printf '${{ matrix.target.image }}@sha256:%s ' *) | |
- name: Create release manifest list and push to registry | |
if: startsWith(github.ref, 'refs/tags/v') | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create --tag "${{ steps.meta.outputs.tags }}"" $(printf '${{ matrix.target.image }}@sha256:%s ' *) | |