ci/woodpecker/push/calendar Pipeline was successful
ci/woodpecker/push/cli Pipeline was successful
ci/woodpecker/push/config Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/jobs Pipeline was successful
ci/woodpecker/push/video-chat Pipeline was successful
ci/woodpecker/push/web Pipeline was successful
ci/woodpecker/push/worker Pipeline was successful
116 lines
3.0 KiB
YAML
116 lines
3.0 KiB
YAML
name: CI/CD (Worker App)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '.github/workflows/worker.yml'
|
|
- 'apps/worker/**'
|
|
- 'packages/**'
|
|
- 'package.json'
|
|
- 'pnpm-workspace.yaml'
|
|
- 'pnpm-lock.yaml'
|
|
tags:
|
|
- '@when/worker@*'
|
|
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '.github/workflows/worker.yml'
|
|
- 'apps/worker/**'
|
|
- 'packages/**'
|
|
- 'package.json'
|
|
- 'pnpm-workspace.yaml'
|
|
- 'pnpm-lock.yaml'
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: apps/worker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 26
|
|
cache: 'pnpm'
|
|
cache-dependency-path: 'pnpm-lock.yaml'
|
|
|
|
- name: Install dependencies
|
|
working-directory: .
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build shared packages
|
|
working-directory: .
|
|
run: pnpm build:packages
|
|
|
|
- name: Lint
|
|
run: pnpm run lint
|
|
|
|
- name: Check
|
|
run: pnpm run check
|
|
|
|
- name: Test
|
|
run: pnpm run test:coverage
|
|
|
|
build-push:
|
|
needs: check
|
|
# Gates only on a pull request: no image is built or pushed.
|
|
if: github.event_name != 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Check Version
|
|
if: github.ref_type == 'tag'
|
|
run: |
|
|
VERSION_FROM_PKG=$(node -p "require('./apps/worker/package.json').version")
|
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
|
VERSION_FROM_TAG=${TAG_NAME#@when/worker@}
|
|
|
|
if [ "$VERSION_FROM_TAG" != "$VERSION_FROM_PKG" ]; then
|
|
echo "Version mismatch: Tag version $VERSION_FROM_TAG does not match package.json version $VERSION_FROM_PKG"
|
|
exit 1
|
|
fi
|
|
echo "Version $VERSION_FROM_PKG matches."
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
images: ghcr.io/${{ github.repository }}-worker
|
|
tags: |
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
type=match,pattern=@when/worker@(\d+),group=1
|
|
type=match,pattern=@when/worker@(\d+\.\d+),group=1
|
|
type=match,pattern=@when/worker@(\d+\.\d+\.\d+),group=1
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
file: apps/worker/Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|