Merge pull request #187 from sethforprivacy/renovate/alpine-3.x #74
This file contains hidden or 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: "Update image when Dockerfile is changed" | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'Dockerfile' | |
workflow_dispatch: | |
env: | |
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/simple-monerod | |
jobs: | |
build: | |
name: "Build container for multiple architectures and push by digest" | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- ubuntu-24.04-arm | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Prepare platform matrix for arm64 | |
if: runner.arch == 'ARM64' | |
run: | | |
echo "PLATFORM=linux/arm64" >> $GITHUB_ENV | |
echo "DIGEST_NAME=arm64" >> $GITHUB_ENV | |
- name: Prepare platform matrix for amd64 | |
if: runner.arch == 'X64' | |
run: | | |
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV | |
echo "DIGEST_NAME=amd64" >> $GITHUB_ENV | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.GHCR_REPO }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.11.1 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3.6.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
- name: Build and and push by digest | |
uses: docker/build-push-action@v6.18.0 | |
id: build | |
with: | |
outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true | |
platforms: ${{ env.PLATFORM }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=${{ env.GHCR_REPO }}:latest | |
- name: Export digest | |
run: | | |
mkdir -p ${{ runner.temp }}/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.DIGEST_NAME }} | |
path: ${{ runner.temp }}/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
name: "Merge digests and push with proper tags" | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v5 | |
with: | |
path: ${{ runner.temp }}/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Login to GHCR | |
uses: docker/login-action@v3.6.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.11.1 | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
- name: Get Monero release tag | |
run: echo MONERO_TAG="$(awk -F '=' '/MONERO_BRANCH=/ {print $2}' Dockerfile)" >> $GITHUB_ENV | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.GHCR_REPO }} | |
tags: | | |
type=sha | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=raw,value=${{ env.MONERO_TAG }} | |
- name: Create manifest list and push | |
working-directory: ${{ runner.temp }}/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }} |