Add Gitea CI workflow for build and deploy
- Move CI config into `.gitea/workflows/steamwarci.yml` - Build with pnpm, sync i18n, and upload `dist/` - Deploy master pushes to `/var/www/html` over SCP
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
name: SteamWar CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
PUBLIC_API_SERVER: https://api.steamwar.de
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 8.14.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Write production environment
|
||||
run: echo "PUBLIC_API_SERVER=${PUBLIC_API_SERVER}" > .env
|
||||
|
||||
- name: Generate i18n files
|
||||
run: pnpm run i18n:sync
|
||||
|
||||
- name: Build website
|
||||
run: pnpm run build
|
||||
|
||||
- name: Upload website artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: steamwar-website
|
||||
path: dist/
|
||||
|
||||
deploy:
|
||||
name: Deploy
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
|
||||
steps:
|
||||
- name: Download website artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: steamwar-website
|
||||
path: dist
|
||||
|
||||
- name: Upload website with scp
|
||||
shell: bash
|
||||
env:
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_PATH: /var/www/html
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
: "${DEPLOY_HOST:?Missing DEPLOY_HOST secret}"
|
||||
: "${DEPLOY_USER:?Missing DEPLOY_USER secret}"
|
||||
: "${DEPLOY_SSH_KEY:?Missing DEPLOY_SSH_KEY secret}"
|
||||
|
||||
port="${DEPLOY_PORT:-22}"
|
||||
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
echo "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -p "$port" "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH' && find '$DEPLOY_PATH' -mindepth 1 -maxdepth 1 -exec rm -rf {} +"
|
||||
scp -i ~/.ssh/deploy_key -P "$port" -r dist/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/"
|
||||
@@ -1,11 +0,0 @@
|
||||
build:
|
||||
- "printenv"
|
||||
- "echo 'PUBLIC_API_SERVER=https://api.steamwar.de' > .env"
|
||||
- "pnpm install"
|
||||
- "./node_modules/.bin/astro-i18n generate:pages --purge"
|
||||
- "./node_modules/.bin/astro-i18n generate:types"
|
||||
- "./node_modules/.bin/astro build"
|
||||
|
||||
release:
|
||||
- "rm -r /var/www/html/*"
|
||||
- "mv dist/* /var/www/html"
|
||||
Reference in New Issue
Block a user