# Preloop Open Source - Release Pipeline
# Builds and pushes Docker images to GitHub Container Registry on releases and main branch
name: Release
on:
push:
branches: [main]
tags: ['v*']
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME_BACKEND: ${{ github.repository }}
IMAGE_NAME_FRONTEND: ${{ github.repository }}/frontend
jobs:
# ==========================================================================
# Build and Push Backend Image
# ==========================================================================
build-backend:
name: Build Backend
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image-tag: ${{ steps.meta.outputs.tags }}
steps:
- 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_NAME_BACKEND }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ==========================================================================
# Build and Push Frontend Image
# ==========================================================================
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- 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_NAME_FRONTEND }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./frontend
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BRAND=preloop
cache-from: type=gha
cache-to: type=gha,mode=max
# ==========================================================================
# Create GitHub Release (on tag)
# ==========================================================================
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-backend, build-frontend]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: --latest --strip header
continue-on-error: true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: |
## Docker Images
```bash
# Backend
docker pull ghcr.io/${{ github.repository }}:${{ github.ref_name }}
# Frontend
docker pull ghcr.io/${{ github.repository }}/frontend:${{ github.ref_name }}
```
## Changelog
${{ steps.changelog.outputs.content }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}