Skip to content

Pin dependencies - autoclosed #5

Pin dependencies - autoclosed

Pin dependencies - autoclosed #5

Workflow file for this run

name: Docker Publish
on:
push:
branches: [main]
tags: ['v*.*.*']
pull_request:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
name: Build and push (${{ matrix.component }})
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- component: backend
context: backend
- component: frontend
context: frontend
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-tags: true
- name: Resolve version
id: version
run: |
raw=$(git describe --tags --always)
tag=${raw#v}
if [ "$raw" = "$(git tag --points-at HEAD)" ]; then
echo "value=v$tag" >> "$GITHUB_OUTPUT"
else
hash=$(git rev-parse --short HEAD)
branch=$(git rev-parse --abbrev-ref HEAD | tr '/' '-')
case "$branch" in
main) echo "value=v$tag-$hash" >> "$GITHUB_OUTPUT" ;;
*) echo "value=v$tag-$branch-$hash" >> "$GITHUB_OUTPUT" ;;
esac
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.component }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: ${{ matrix.context }}
build-args: VERSION=${{ steps.version.outputs.value }}
secrets: SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.component }}
cache-to: type=gha,mode=max,scope=${{ matrix.component }}