Skip to content

Merge pull request #94 from fhem/renovate/docker-setup-qemu-action-3.x #158

Merge pull request #94 from fhem/renovate/docker-setup-qemu-action-3.x

Merge pull request #94 from fhem/renovate/docker-setup-qemu-action-3.x #158

name: Docker-publish
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
release:
types:
- published
push:
branches:
- main
- 'releases/**'
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Split fhempy Version
id: split_fhempyV
run: |
echo "::set-output name=result::$(grep '^fhempy' requirements.txt | cut -d '=' -f3)"
- name: Find String
id: extract_image
run: |
echo "::set-output name=image_name::$(grep '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f1)"
echo "::set-output name=image_version::$(grep '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f2)"
- name: Update docs
if: ${{ github.event_name == 'release' }}
run: |
sed -e "s/{FHEMPY_VERSION}/${{ steps.split_fhempyV.outputs.result}}/" -e "s/{PYTHON_VERSION}/${{ steps.extract_image.outputs.image_version}}/" -e "s/{DEBIAN_RELEASE}/buster/" -e s/{IMAGE_TAG}/${{ github.ref_name }}/ < README.tmpl > README.md
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name == 'release'
uses: sigstore/cosign-installer@v2.8.1
with:
cosign-release: 'v1.9.0'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build image and run integrationtests (amd64)
id: build_and_run_integrationtests
uses: ./.github/actions/integrationtest
with:
PLATTFORM: linux/amd64
FHEMPY_VERSION: ${{ steps.split_fhempyV.outputs.result }}
# Login against a Docker registry if it is a release
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name == 'release'
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push if it is not a release)
# https://github.com/docker/build-push-action
- name: Build base image for all plattforms
id: build_base_cross
uses: docker/build-push-action@v4.1.0
with:
context: .
platforms: linux/amd64,linux/arm/v5
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=verify_base_linux/amd64
type=gha,scope=verify_base_cross
cache-to: type=gha,mode=max,scope=verify_base_cross
build-args: FHEMPY_V=${{ steps.split_fhempyV.outputs.result}}
target: base
- name: Build and push Docker image for all plattforms
uses: docker/build-push-action@v4.1.0
id: docker_build_runtime_cross
with:
context: .
platforms: linux/amd64,linux/arm/v5
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=verify_base_cross
type=gha,scope=verify_runtime_linux/amd64
type=gha,scope=publish_runtime_cross
cache-to: type=gha,mode=max,scope=publish_runtime_cross
build-args: FHEMPY_V=${{ steps.split_fhempyV.outputs.result}}
target: runtime
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name == 'release' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.docker_build_runtime_cross.outputs.digest }}
- name: git commit README.md
id: commit
if: ${{ github.event_name == 'release' }}
run: |
git config --global user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "README.md: Update Versions" -a && echo "::set-output name=status::true" || true
- name: Push back to protected branch (main)
uses: CasperWA/push-protected@v2
if: ${{ github.event_name == 'release' }}
with:
token: ${{ secrets.BOT_PUSH_TOKEN }}
branch: main
#unprotect_reviews: true