Dev #1
@@ -5,8 +5,9 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: linux-x64
|
||||
@@ -33,8 +34,9 @@ jobs:
|
||||
- name: Security audit
|
||||
run: npm audit
|
||||
|
||||
- name: Deploy dev
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
|
||||
|
||||
- name: Deploy website
|
||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main')
|
||||
env:
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
@@ -42,6 +44,19 @@ jobs:
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
case "$GITHUB_REF" in
|
||||
refs/heads/dev)
|
||||
DEPLOY_PATH="/var/MoorlyWeb/dev/"
|
||||
;;
|
||||
refs/heads/main)
|
||||
DEPLOY_PATH="/var/MoorlyWeb/production/"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported branch: $GITHUB_REF"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
KEY_FILE="$(mktemp)"
|
||||
trap 'rm -f "$KEY_FILE"' EXIT
|
||||
|
||||
@@ -50,5 +65,5 @@ jobs:
|
||||
|
||||
rsync -az --delete \
|
||||
-e "ssh -i $KEY_FILE -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts" \
|
||||
dist/ "${DEPLOY_USER}@${DEPLOY_HOST}:/var/MoorlyWeb/dev/"
|
||||
dist/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
|
||||
|
||||
Reference in new issue
Block a user