Skip to content

Docker

Docker #347

name: Docker
on:
workflow_dispatch:
push:
branches: [ main ]
tags: [ 'v*.*.*' ]
schedule:
- cron: '37 1 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
WRITEFREELY_VERSION: v0.15.1
DOCKERHUB_REPO: jrasanen/writefreely
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
labels: ${{ steps.meta.outputs.labels }}
build-args: |
WRITEFREELY_VERSION=${{ env.WRITEFREELY_VERSION }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ env.WRITEFREELY_VERSION }}
${{ env.DOCKERHUB_REPO }}:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max