Skip to content

v0.0.16

v0.0.16 #14

Workflow file for this run

name: Release
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAMESPACE: emoss08/trenova
TMS_IMAGE_NAME: emoss08/trenova/tms
CLIENT_IMAGE_NAME: emoss08/trenova/client
jobs:
detect-postgres-changes:
name: Detect Postgres Image Changes
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
should_build: ${{ steps.detect.outputs.should_build }}
previous_tag: ${{ steps.detect.outputs.previous_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect Postgres image changes
id: detect
shell: bash
run: |
set -euo pipefail
current_ref="${GITHUB_REF_NAME}"
previous_tag="$(git tag --sort=-v:refname | grep -v "^${current_ref}$" | head -n 1 || true)"
if [[ -z "${previous_tag}" ]]; then
echo "No previous tag found; building Postgres image."
echo "should_build=true" >> "${GITHUB_OUTPUT}"
echo "previous_tag=" >> "${GITHUB_OUTPUT}"
exit 0
fi
changed_files="$(git diff --name-only "${previous_tag}" "${current_ref}" -- deploy/Dockerfile.postgres)"
if [[ -n "${changed_files}" ]]; then
echo "Postgres image inputs changed since ${previous_tag}:"
echo "${changed_files}"
echo "should_build=true" >> "${GITHUB_OUTPUT}"
else
echo "Postgres image inputs did not change since ${previous_tag}; skipping Postgres image build."
echo "should_build=false" >> "${GITHUB_OUTPUT}"
fi
echo "previous_tag=${previous_tag}" >> "${GITHUB_OUTPUT}"
build-and-push-tms:
name: Build and Push TMS Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.TMS_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- name: Build and push TMS image
uses: docker/build-push-action@v6
with:
context: .
file: ./deploy/Dockerfile.tms
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
build-and-push-client:
name: Build and Push Client Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.CLIENT_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- name: Build and push Client image
uses: docker/build-push-action@v6
with:
context: .
file: ./deploy/Dockerfile.client
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
VITE_API_URL=/api/v1
build-and-push-postgres:
name: Build and Push Postgres Image
runs-on: ubuntu-latest
needs: detect-postgres-changes
if: needs.detect-postgres-changes.outputs.should_build == 'true'
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/postgres
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- name: Build and push Postgres image
uses: docker/build-push-action@v6
with:
context: ./deploy
file: ./deploy/Dockerfile.postgres
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64