name: Validate Docker builds
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
validate-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Compute image name
id: vars
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
run: echo "image=${IMAGE_NAME,,}" >> "$GITHUB_OUTPUT"
- name: Build (no push) - snak-api
uses: docker/build-push-action@v6
with:
context: .
file: ./packages/server/Dockerfile
push: false
platforms: linux/amd64
load: true
tags: ${{ env.REGISTRY }}/${{ steps.vars.outputs.image }}:build-validation
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test server image
run: |
docker run --rm \
--entrypoint node \
${{ env.REGISTRY }}/${{ steps.vars.outputs.image }}:build-validation \
--version