Add Docker Deployment Workflow
Some checks failed
CI / Lint & Typecheck (push) Successful in 2m17s
CI / Test (routes) (push) Successful in 1m17s
CI / Test (security) (push) Successful in 1m27s
CI / Test (services) (push) Successful in 1m18s
CI / Test (unit) (push) Successful in 1m35s
CI / Test (integration) (push) Successful in 2m17s
CI / Test Coverage (push) Failing after 1m49s
CI / Build (push) Has been skipped
CI / Deploy Tracearr (push) Has been skipped
Nightly / Check for changes (push) Failing after 4s
Nightly / Build & Push Docker (push) Has been skipped
Nightly / Build & Push Supervised Image (push) Has been skipped
Some checks failed
CI / Lint & Typecheck (push) Successful in 2m17s
CI / Test (routes) (push) Successful in 1m17s
CI / Test (security) (push) Successful in 1m27s
CI / Test (services) (push) Successful in 1m18s
CI / Test (unit) (push) Successful in 1m35s
CI / Test (integration) (push) Successful in 2m17s
CI / Test Coverage (push) Failing after 1m49s
CI / Build (push) Has been skipped
CI / Deploy Tracearr (push) Has been skipped
Nightly / Check for changes (push) Failing after 4s
Nightly / Build & Push Docker (push) Has been skipped
Nightly / Build & Push Supervised Image (push) Has been skipped
This commit is contained in:
80
.github/workflows/ci.yml
vendored
80
.github/workflows/ci.yml
vendored
@@ -7,6 +7,9 @@ on:
|
|||||||
types: [opened, synchronize]
|
types: [opened, synchronize]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# ---------------------------------
|
||||||
|
# Lint & Typecheck
|
||||||
|
# ---------------------------------
|
||||||
lint-and-typecheck:
|
lint-and-typecheck:
|
||||||
name: Lint & Typecheck
|
name: Lint & Typecheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -16,22 +19,20 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Enable pnpm
|
- name: Enable pnpm
|
||||||
run: corepack enable
|
run: corepack enable
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: pnpm lint
|
run: pnpm lint
|
||||||
|
|
||||||
- name: Typecheck
|
- name: Typecheck
|
||||||
run: pnpm typecheck
|
run: pnpm typecheck
|
||||||
|
|
||||||
|
# ---------------------------------
|
||||||
|
# Unit / Service / Route / Security Tests
|
||||||
|
# ---------------------------------
|
||||||
test:
|
test:
|
||||||
name: Test (${{ matrix.group }})
|
name: Test (${{ matrix.group }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -41,27 +42,24 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
group: [unit, services, routes, security]
|
group: [unit, services, routes, security]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Enable pnpm
|
- name: Enable pnpm
|
||||||
run: corepack enable
|
run: corepack enable
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build dependencies (shared, test-utils)
|
- name: Build dependencies (shared, test-utils)
|
||||||
run: pnpm turbo run build --filter=@tracearr/shared --filter=@tracearr/test-utils
|
run: pnpm turbo run build --filter=@tracearr/shared --filter=@tracearr/test-utils
|
||||||
|
|
||||||
- name: Run ${{ matrix.group }} tests
|
- name: Run ${{ matrix.group }} tests
|
||||||
run: pnpm --filter @tracearr/server test:${{ matrix.group }}
|
run: pnpm --filter @tracearr/server test:${{ matrix.group }}
|
||||||
|
|
||||||
|
# ---------------------------------
|
||||||
|
# Integration Tests (TimescaleDB + Redis)
|
||||||
|
# ---------------------------------
|
||||||
test-integration:
|
test-integration:
|
||||||
name: Test (integration)
|
name: Test (integration)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -73,7 +71,6 @@ jobs:
|
|||||||
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
||||||
TEST_DATABASE_URL: postgresql://test:test@timescale:5432/tracearr_test
|
TEST_DATABASE_URL: postgresql://test:test@timescale:5432/tracearr_test
|
||||||
TEST_REDIS_URL: redis://redis:6379
|
TEST_REDIS_URL: redis://redis:6379
|
||||||
|
|
||||||
services:
|
services:
|
||||||
timescale:
|
timescale:
|
||||||
image: timescale/timescaledb:latest-pg15
|
image: timescale/timescaledb:latest-pg15
|
||||||
@@ -86,7 +83,6 @@ jobs:
|
|||||||
--health-interval 5s
|
--health-interval 5s
|
||||||
--health-timeout 3s
|
--health-timeout 3s
|
||||||
--health-retries 10
|
--health-retries 10
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
options: >-
|
options: >-
|
||||||
@@ -94,22 +90,20 @@ jobs:
|
|||||||
--health-interval 5s
|
--health-interval 5s
|
||||||
--health-timeout 3s
|
--health-timeout 3s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Enable pnpm
|
- name: Enable pnpm
|
||||||
run: corepack enable
|
run: corepack enable
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build dependencies (shared, test-utils)
|
- name: Build dependencies (shared, test-utils)
|
||||||
run: pnpm turbo run build --filter=@tracearr/shared --filter=@tracearr/test-utils
|
run: pnpm turbo run build --filter=@tracearr/shared --filter=@tracearr/test-utils
|
||||||
|
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
run: pnpm --filter @tracearr/server test:integration
|
run: pnpm --filter @tracearr/server test:integration
|
||||||
|
|
||||||
|
# ---------------------------------
|
||||||
|
# Test Coverage
|
||||||
|
# ---------------------------------
|
||||||
test-coverage:
|
test-coverage:
|
||||||
name: Test Coverage
|
name: Test Coverage
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -119,24 +113,18 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Enable pnpm
|
- name: Enable pnpm
|
||||||
run: corepack enable
|
run: corepack enable
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build dependencies (shared, test-utils)
|
- name: Build dependencies (shared, test-utils)
|
||||||
run: pnpm turbo run build --filter=@tracearr/shared --filter=@tracearr/test-utils
|
run: pnpm turbo run build --filter=@tracearr/shared --filter=@tracearr/test-utils
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: pnpm test:coverage
|
run: pnpm test:coverage
|
||||||
|
|
||||||
- name: Upload coverage reports
|
- name: Upload coverage reports
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: coverage-report
|
name: coverage-report
|
||||||
@@ -144,6 +132,9 @@ jobs:
|
|||||||
retention-days: 7
|
retention-days: 7
|
||||||
if-no-files-found: warn
|
if-no-files-found: warn
|
||||||
|
|
||||||
|
# ---------------------------------
|
||||||
|
# Build App
|
||||||
|
# ---------------------------------
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -158,15 +149,46 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Enable pnpm
|
- name: Enable pnpm
|
||||||
run: corepack enable
|
run: corepack enable
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|
||||||
|
# ---------------------------------
|
||||||
|
# Deploy to Docker
|
||||||
|
# ---------------------------------
|
||||||
|
deploy:
|
||||||
|
name: Deploy Tracearr
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: docker:26-cli
|
||||||
|
needs: build
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
env:
|
||||||
|
REGISTRY: gitea.yourdomain.co.nz
|
||||||
|
IMAGE_NAME: tracearr
|
||||||
|
IMAGE_TAG: latest
|
||||||
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Login to Gitea registry
|
||||||
|
run: |
|
||||||
|
echo "${REGISTRY_TOKEN}" | docker login $REGISTRY \
|
||||||
|
-u "${REGISTRY_USER}" --password-stdin
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
-t $REGISTRY/$REGISTRY_USER/$IMAGE_NAME:$IMAGE_TAG \
|
||||||
|
-f docker/Dockerfile .
|
||||||
|
- name: Push Docker image
|
||||||
|
run: |
|
||||||
|
docker push $REGISTRY/$REGISTRY_USER/$IMAGE_NAME:$IMAGE_TAG
|
||||||
|
- name: Deploy via docker compose
|
||||||
|
run: |
|
||||||
|
docker compose -f docker/docker-compose.yml pull
|
||||||
|
docker compose -f docker/docker-compose.yml up -d
|
||||||
|
|||||||
Reference in New Issue
Block a user