Files
book-test/.gitea/workflows/ci-cd.yml
T
chris 62c0f4e445
CI/CD Pipeline / test (push) Failing after 27s
CI/CD Pipeline / deploy-internal (push) Skipped
Remove network, ignored; use 127.0.0.1
2026-09-25 13:27:52 -04:00

89 lines
2.9 KiB
YAML

name: CI/CD Pipeline
on:
workflow_dispatch:
push:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
# Run a temporary Postgres container next to your build container
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: ${{ secrets.TEST_PG_USER }}
POSTGRES_PASSWORD: ${{ secrets.TEST_PG_USER_PASSWORD }}
POSTGRES_DB: ${{ secrets.TEST_PG_DATABASE }}
ports:
- ${{ secrets.TEST_PG_PORT }}:5432
# Ensure Postgres is completely booted before running tests
options: >-
--health-cmd "pg_isready -U test_user -d test_db"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-node-version: '20'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Download dbmate
run: |
sudo curl -fsSL -o /usr/local/bin/dbmate https://github.com
sudo chmod +x /usr/local/bin/dbmate
- name: Run Migrations against Test Database
working-directory: ./api
run: npx dbmate up
env:
DATABASE_URL: "postgres://${{ secrets.TEST_PG_USER }}:${{ secrets.TEST_PG_USER_PASSWORD }}@127.0.0.1:@${{ secrets.TEST_PG_PORT }}/${{ secrets.TEST_PG_DATABASE }}?sslmode=disable"
# - name: Generate PgTyped Types
# run: npm run pgtyped:compile
# env:
# DATABASE_URL: "postgres://test_user:test_password@saber.home.lan:5433/test_db?sslmode=disable"
# - name: Run Application Tests
# run: npm test
# env:
# DATABASE_URL: "postgres://test_user:test_password@saber.home.lan:5433/test_db?sslmode=disable"
deploy-internal:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
# 1. Update the live internal database instance
- name: Apply DB Migrations to Live Internal DB
working-directory: ./api
run: |
sudo curl -fsSL -o /usr/local/bin/dbmate https://github.com && sudo chmod +x /usr/local/bin/dbmate
npx dbmate up
env:
DATABASE_URL: "postgres://${{ secrets.INTERNAL_PG_USER }}:${{ secrets.INTERNAL_PG_USER_PASSWORD }}@${{ secrets.INTERNAL_PG_HOST }}:${{ secrets.INTERNAL_PG_PORT }}/${{ secrets.INTERNAL_PG_DATABASE }}"
# # 2. Deploy your application code (Example: Rebuilding a local container)
# - name: Deploy Container to Internal Server via SSH
# uses: appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.INTERNAL_SERVER_IP }}
# username: ${{ secrets.INTERNAL_SERVER_USER }}
# key: ${{ secrets.INTERNAL_SSH_PRIVATE_KEY }}
# script: |
# cd /opt/my-app
# git pull origin main
# docker compose up -d --build