v2.1.2 #3
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 Release | |
on: | |
release: | |
types: [ published, edited ] | |
workflow_dispatch: | |
inputs: | |
no_cache: | |
type: boolean | |
description: 'Build from scratch, without using cached layers' | |
env: | |
IMAGE_NAME: slock | |
DEPLOY_IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/slock | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to Docker hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# slashes are not allowed in image tags, but can appear in git branch or tag names | |
- id: sanitize_tag | |
name: Sanitize image tag | |
run: echo tag=${raw_tag//\//-} >> $GITHUB_OUTPUT | |
env: | |
raw_tag: ${{ github.ref_name }} | |
- id: build | |
name: Build image | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: BUILD_TYPE=release | |
load: true # save to docker images | |
# push: true # TODO: uncomment when this issue is fixed: https://github.com/moby/buildkit/issues/1555 | |
tags: > | |
${{ env.IMAGE_NAME }}, | |
${{ env.DEPLOY_IMAGE_NAME }}:latest, | |
${{ env.DEPLOY_IMAGE_NAME }}:${{ steps.sanitize_tag.outputs.tag }} | |
# cache layers in GitHub Actions cache to speed up builds | |
cache-from: ${{ !inputs.no_cache && 'type=gha' || '' }},scope=docker-release | |
cache-to: type=gha,scope=docker-release,mode=max | |
- name: Push image to Docker Hub | |
run: docker push --all-tags ${{ env.DEPLOY_IMAGE_NAME }} |