153 lines
4.1 KiB
YAML
153 lines
4.1 KiB
YAML
name: Build and Push Multi-Arch Images
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master, 'feature/*']
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [main, master]
|
|
|
|
env:
|
|
REGISTRY: gitea-gitea-http.taildb3494.ts.net
|
|
|
|
jobs:
|
|
test-and-typecheck:
|
|
name: Test and Typecheck
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Run TypeScript typecheck
|
|
run: bun run typecheck
|
|
|
|
- name: Run tests
|
|
run: bash run_tests.sh
|
|
|
|
build-web:
|
|
name: Build Web Image (Multi-Arch)
|
|
runs-on: ubuntu-latest
|
|
needs: test-and-typecheck
|
|
if: github.event_name != 'pull_request'
|
|
steps:
|
|
- name: Checkout
|
|
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: Login to Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.repository_owner }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ gitea.repository_owner }}/porthole-web
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix=,suffix=,format=short
|
|
|
|
- name: Build and push web image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./apps/web/Dockerfile
|
|
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-worker:
|
|
name: Build Worker Image (Multi-Arch)
|
|
runs-on: ubuntu-latest
|
|
needs: test-and-typecheck
|
|
if: github.event_name != 'pull_request'
|
|
steps:
|
|
- name: Checkout
|
|
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: Login to Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.repository_owner }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ gitea.repository_owner }}/porthole-worker
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix=,suffix=,format=short
|
|
|
|
- name: Build and push worker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./apps/worker/Dockerfile
|
|
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-pr:
|
|
name: Build Images (PR Only - No Push)
|
|
runs-on: ubuntu-latest
|
|
needs: test-and-typecheck
|
|
if: github.event_name == 'pull_request'
|
|
strategy:
|
|
matrix:
|
|
app: [web, worker]
|
|
steps:
|
|
- name: Checkout
|
|
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: Build image (no push)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./apps/${{ matrix.app }}/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: false
|
|
cache-from: type=gha
|