86 lines
3.1 KiB
YAML
86 lines
3.1 KiB
YAML
name: Test, deploy, and browser-test System Landscape Simulator
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test-build:
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- run: node --version && npm --version
|
|
- run: npm ci --include=dev --prefer-offline --no-audit --no-fund
|
|
- run: npm test
|
|
- run: npm run build
|
|
|
|
deploy:
|
|
if: ${{ gitea.event_name == 'push' }}
|
|
needs: test-build
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- name: Load deployment SSH key
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
- name: Deploy to port 7004
|
|
shell: bash
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
run: |
|
|
set -Eeuo pipefail
|
|
mkdir -p ~/.ssh
|
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
|
ssh -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" '
|
|
set -Eeuo pipefail
|
|
TARGET_DIR=/mnt/appdata/prod/SystemLandscapeSimulator
|
|
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/SystemLandscapeSimulator.git
|
|
mkdir -p "$TARGET_DIR"
|
|
if [ ! -d "$TARGET_DIR/.git" ]; then
|
|
git init "$TARGET_DIR"
|
|
git -C "$TARGET_DIR" remote add origin "$REPO_URL"
|
|
else
|
|
git -C "$TARGET_DIR" remote set-url origin "$REPO_URL"
|
|
fi
|
|
GIT_SSH_COMMAND="ssh -p 222 -o StrictHostKeyChecking=no" git -C "$TARGET_DIR" fetch origin main
|
|
git -C "$TARGET_DIR" reset --hard origin/main
|
|
git -C "$TARGET_DIR" clean -fdx
|
|
docker ps -q --filter publish=7004 | xargs -r docker rm -f
|
|
docker compose -p system-landscape-simulator -f "$TARGET_DIR/docker-compose.yml" down --remove-orphans || true
|
|
SYSTEM_LANDSCAPE_PORT=7004 docker compose -p system-landscape-simulator -f "$TARGET_DIR/docker-compose.yml" build
|
|
SYSTEM_LANDSCAPE_PORT=7004 docker compose -p system-landscape-simulator -f "$TARGET_DIR/docker-compose.yml" up -d
|
|
'
|
|
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12; do
|
|
curl --fail --silent --show-error --max-time 15 http://192.168.1.15:7004/healthz && exit 0
|
|
sleep 5
|
|
done
|
|
exit 1
|
|
|
|
browser-test:
|
|
if: ${{ gitea.event_name == 'push' }}
|
|
needs: deploy
|
|
timeout-minutes: 20
|
|
runs-on: docker
|
|
env:
|
|
E2E_BASE_URL: https://syssim.dumas.ddns.net
|
|
PLAYWRIGHT_BROWSERS_PATH: .playwright
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
- run: npm ci --include=dev --prefer-offline --no-audit --no-fund
|
|
- run: npx playwright install --with-deps chromium
|
|
- run: npm run test:ui
|
|
|