51 lines
1.3 KiB
YAML
51 lines
1.3 KiB
YAML
name: Deploy website
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out source
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Install dependencies
|
|
run: bun install --no-progress
|
|
|
|
- name: Build site
|
|
run: bun run build
|
|
|
|
- name: Configure SSH
|
|
env:
|
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
|
run: |
|
|
install -d -m 700 "$HOME/.ssh"
|
|
printf '%s\n' "$DEPLOY_SSH_KEY" > "$HOME/.ssh/deploy_key"
|
|
chmod 600 "$HOME/.ssh/deploy_key"
|
|
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts"
|
|
|
|
- name: Deploy dist/
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
|
run: |
|
|
set -o pipefail
|
|
tar -C dist -czf - . | \
|
|
ssh -T -i "$HOME/.ssh/deploy_key" -o IdentitiesOnly=yes \
|
|
"$DEPLOY_USER@$DEPLOY_HOST" \
|
|
"find '$DEPLOY_PATH' -mindepth 1 -maxdepth 1 -exec rm -rf -- {} + && tar -xzf - -C '$DEPLOY_PATH'"
|