Workflow improvements #21
Workflow file for this run
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: Publish Docker image | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker hub | |
runs-on: ubuntu-latest | |
environment: | |
name: Build Docker images | |
strategy: | |
fail-fast: false | |
max-parallel: 4 | |
matrix: | |
include: | |
# All non supported by base image are commented | |
- { platform: "linux/arm64", platform-tag: "arm64" } | |
- { platform: "linux/amd64", platform-tag: "amd64" } | |
- { platform: "linux/arm/v7", platform-tag: "armv7" } | |
- { platform: "linux/arm/v6", platform-tag: "armv6" } | |
- { platform: "linux/ppc64le", platform-tag: "ppc64le" } | |
#- { platform: "linux/riscv64", platform-tag: "riscv64" } | |
- { platform: "linux/s390x", platform-tag: "s390x" } | |
- { platform: "linux/386", platform-tag: "386" } | |
#- { platform: "linux/mips64le", platform-tag: "mips64le" } | |
#- { platform: "linux/mips64", platform-tag: "mips64" } | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }} | |
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }} | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push image | |
run: make docker-build docker-push | |
env: | |
DOCKER_BUILDKIT: 1 | |
PLATFORM: "${{ matrix.platform }}" | |
IMAGE_TAG: "docker.io/botsudo/nut-upsd:${{ matrix.platform-tag }}-latest" | |
- name: Sign and push docker image | |
uses: sudo-bot/action-docker-sign@latest | |
with: | |
image-ref: "docker.io/botsudo/nut-upsd:${{ matrix.platform-tag }}-latest" | |
private-key-id: "${{ vars.DOCKER_PRIVATE_KEY_ID }}" | |
private-key: ${{ secrets.DOCKER_PRIVATE_KEY }} | |
private-key-passphrase: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }} | |
sign-manifest: | |
name: Sign the docker hub manifest | |
runs-on: ubuntu-latest | |
needs: push_to_registry | |
environment: | |
name: Sign Docker manifest | |
steps: | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }} | |
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }} | |
- name: Create a manifest | |
env: | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
run: | | |
docker manifest create docker.io/botsudo/nut-upsd:latest \ | |
docker.io/botsudo/nut-upsd:arm64-latest \ | |
docker.io/botsudo/nut-upsd:amd64-latest \ | |
docker.io/botsudo/nut-upsd:armv7-latest \ | |
docker.io/botsudo/nut-upsd:armv6-latest \ | |
docker.io/botsudo/nut-upsd:ppc64le-latest \ | |
docker.io/botsudo/nut-upsd:s390x-latest \ | |
docker.io/botsudo/nut-upsd:386-latest \ | |
--amend | |
- name: Sign and push the manifest | |
uses: sudo-bot/action-docker-sign@latest | |
with: | |
image-ref: "docker.io/botsudo/nut-upsd:latest" | |
# Using the repository key to sign it | |
private-key-id: "${{ vars.DOCKER_PRIVATE_KEY_ID }}" | |
private-key: ${{ secrets.DOCKER_PRIVATE_KEY }} | |
private-key-passphrase: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }} | |
sign-manifest: true | |
notary-auth: "${{ secrets.DOCKER_REPOSITORY_LOGIN }}:${{ secrets.DOCKER_REPOSITORY_PASSWORD }}" |