Skip to content

Publish

Publish #7

Workflow file for this run

name: Publish
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [master]
push:
tags: v[0-9]+.[0-9]+.[0-9]+-*
env:
CARGO_TERM_COLOR: always
DOCKER_REPO: leonardoarcari/dcapal
jobs:
extract-tag-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract tag version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Echo tag version
run: |
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
build-publish-docker-image:
runs-on: ubuntu-22.04
needs: [extract-tag-version]
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./dcapal-backend/docker/Dockerfile
push: true
tags: ${{ env.DOCKER_REPO }}:latest${{ startsWith(env.RELEASE_VERSION, 'v') && format(',{0}:{1}', env.DOCKER_REPO, env.RELEASE_VERSION) || ''}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache