89 lines
2.3 KiB
YAML
89 lines
2.3 KiB
YAML
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: Compile i18n files
|
|
run: pnpm run i18n:compile
|
|
|
|
- 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/"
|