Skip to content

Merge pull request #19 from kosminus/test/query-pipeline-integration #2

Merge pull request #19 from kosminus/test/query-pipeline-integration

Merge pull request #19 from kosminus/test/query-pipeline-integration #2

Workflow file for this run

name: Release
# Build + push the two production images, then deploy with Helm:
# push to main -> build -> deploy to STAGING
# push tag v* -> build -> deploy to PRODUCTION (gated by the environment's
# required reviewers)
# manual -> build only (workflow_dispatch)
#
# Required GitHub Environment secrets:
# staging / production: KUBE_CONFIG (base64-encoded kubeconfig for the cluster)
# Images push to GHCR using the built-in GITHUB_TOKEN (packages: write).
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
REGISTRY: ghcr.io
jobs:
images:
name: Build & push (${{ matrix.component }})
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- component: backend
context: backend
dockerfile: backend/Dockerfile.prod
- component: frontend
context: frontend
dockerfile: frontend/Dockerfile.prod
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/querywise-${{ matrix.component }}
tags: |
type=raw,value=${{ github.sha }}
type=ref,event=branch
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build & push
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Frontend is built same-origin; nginx proxies /api to the backend.
build-args: ${{ matrix.component == 'frontend' && 'VITE_API_URL=' || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-staging:
name: Deploy to staging
needs: images
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/helm-deploy
with:
environment: staging
image_tag: ${{ github.sha }}
kube_config: ${{ secrets.KUBE_CONFIG }}
deploy-prod:
name: Deploy to production
needs: images
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/helm-deploy
with:
environment: production
image_tag: ${{ github.sha }}
kube_config: ${{ secrets.KUBE_CONFIG }}