Docker image build and push #171
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: Docker image build and push | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: "The branch to build the Docker image from" | |
required: false | |
default: "master" | |
release: | |
types: [created] | |
jobs: | |
build-and-push-docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.inputs.branch || github.ref_name }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Install dependencies | |
run: npm install | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set Docker tags | |
id: docker_meta | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
TAGS="freikin/dawarich:${VERSION}" | |
# Add :rc tag for pre-releases | |
if [ "${{ github.event.release.prerelease }}" = "true" ]; then | |
TAGS="${TAGS},freikin/dawarich:rc" | |
fi | |
# Add :latest tag only if release is not a pre-release | |
if [ "${{ github.event.release.prerelease }}" != "true" ]; then | |
TAGS="${TAGS},freikin/dawarich:latest" | |
fi | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
- name: Build and push (arm64) | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./docker/Dockerfile.dev | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
platforms: linux/arm64 | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-arm64 | |
- name: Build and push (other architectures) | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./docker/Dockerfile.dev | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
platforms: linux/amd64,linux/arm/v7,linux/arm/v6 | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache |