Files
book-test/.gitea/workflows/ci-cd.yml
T
chris bd30405048
CI/CD Pipeline / test (push) Successful in 1m40s
CI/CD Pipeline / deploy-internal (push) Failing after 1m5s
Commented npm test block until later
2026-08-26 15:06:07 -04:00

87 lines
2.5 KiB
YAML

name: CI/CD Pipeline
on:
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: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_db
ports:
- 5433: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
run: |
npx dbmate up
env:
DATABASE_URL: "postgres://test_user:test_password@saber.home.lan:5433/test_db?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
run: |
sudo curl -fsSL -o /usr/local/bin/dbmate https://github.com && sudo chmod +x /usr/local/bin/dbmate
dbmate up
env:
DATABASE_URL: ${{ secrets.INTERNAL_PROD_DB_URL }}
# 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