82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
name: Continuous Integration
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
REGISTRY: gitea.lucaswinther.info
|
|
|
|
jobs:
|
|
lint-and-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Typecheck
|
|
run: bunx tsc --noEmit
|
|
- name: Run test suite
|
|
run: bun test
|
|
- name: Build app
|
|
run: bun run build
|
|
|
|
docker-build-and-push:
|
|
runs-on: ubuntu-latest
|
|
needs: [lint-and-test]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# Gitea's job token cannot publish packages; use a package-write PAT.
|
|
- name: Log in to Gitea Container Registry
|
|
if: gitea.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ gitea.repository }}
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=sha,prefix=sha-
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: ${{ gitea.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Pull and smoke-test published image
|
|
if: gitea.event_name != 'pull_request'
|
|
env:
|
|
PUBLISHED_TAGS: ${{ steps.meta.outputs.tags }}
|
|
run: |
|
|
image="$(printf '%s\n' "$PUBLISHED_TAGS" | head -n 1)"
|
|
docker pull "$image"
|
|
docker run -d --rm -p 3000:3000 --name budget2-ci "$image"
|
|
trap 'docker stop budget2-ci' EXIT
|
|
for i in $(seq 1 30); do
|
|
if curl -fsS http://localhost:3000/ > /dev/null; then break; fi
|
|
sleep 1
|
|
done
|
|
curl -fsS http://localhost:3000/ | grep -q "Budget"
|
|
curl -fsS http://localhost:3000/sw.js > /dev/null
|
|
curl -fsS http://localhost:3000/manifest.webmanifest > /dev/null
|