Build Multi Stage Docker Image #405
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: Build Multi Stage Docker Image | |
on: | |
push: | |
branches-ignore: | |
- 'dependabot/**' | |
workflow_dispatch: | |
schedule: | |
- cron: '0 5 * * *' | |
jobs: | |
GHRC: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- uses: FranzDiebold/[email protected] | |
- name: Print environment variables | |
run: | | |
echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME" | |
- name: Prepare GHRC.io | |
id: prep | |
run: | | |
REPO=$CI_REPOSITORY_NAME | |
DOCKER_IMAGE=${{ github.repository_owner }}/${REPO} | |
if [ "$CI_REF_NAME" != "dev" ]; then | |
VERSION=latest | |
else | |
VERSION=nightly | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "title=${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
with: | |
platforms: linux/amd64,linux/armhf,linux/arm64 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/[email protected] | |
- name: Cache Docker layers | |
uses: actions/[email protected] | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Build and push GHRC.io | |
id: docker_build | |
uses: docker/[email protected] | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/armhf,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ghcr.io/${{ steps.prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.title=${{ steps.prep.outputs.title }} | |
org.opencontainers.image.version=${{ steps.prep.outputs.version }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |