This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: Deploy site
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
# Configure in Gitea: Settings → Actions → Secrets / Variables.
|
||||
# vars.DEPLOY_TARGET where built files go, e.g. /var/www/dylanbenzi.com/ or user@host:/var/www/site/
|
||||
# secrets.DEPLOY_SSH_KEY private key for an ssh target (omit if the runner can write to the target directly)
|
||||
# vars.SITE_URL optional, e.g. https://dylanbenzi.com
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm build
|
||||
env:
|
||||
SITE_URL: ${{ vars.SITE_URL }}
|
||||
- name: Deploy
|
||||
env:
|
||||
TARGET: ${{ vars.DEPLOY_TARGET }}
|
||||
KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -n "$TARGET" || { echo "DEPLOY_TARGET is not set"; exit 1; }
|
||||
if [ -n "$KEY" ]; then
|
||||
mkdir -p ~/.ssh && printf '%s\n' "$KEY" > ~/.ssh/deploy_key && chmod 600 ~/.ssh/deploy_key
|
||||
rsync -az --delete -e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=accept-new" dist/ "$TARGET"
|
||||
else
|
||||
rsync -az --delete dist/ "$TARGET"
|
||||
fi
|
||||
Reference in New Issue
Block a user