Skip to content

Publish

Publish #53

Workflow file for this run

name: Publish
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
schedule:
- cron: '0 0 * * *' # daily
env:
DOCKER_BUILDKIT: 1
DOCKER_IMAGE: ghcr.io/zaherg/umami-postgres
DOCKER_IMAGE_VERSION: latest
TRIVY_VERSION: 0.32.0
jobs:
github:
name: Build & Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
max-parallel: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ env.DOCKER_IMAGE }}
VERSION=${{ env.DOCKER_IMAGE_VERSION }}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: "all"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- 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: Login to Github Package Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build for multi-platform
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64/v8
builder: ${{ steps.buildx.outputs.name }}
file: Dockerfile
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache