Dev #1
@@ -5,8 +5,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: linux-x64
|
runs-on: linux-x64
|
||||||
@@ -33,8 +34,9 @@ jobs:
|
|||||||
- name: Security audit
|
- name: Security audit
|
||||||
run: npm 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:
|
env:
|
||||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
@@ -42,6 +44,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -eu
|
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)"
|
KEY_FILE="$(mktemp)"
|
||||||
trap 'rm -f "$KEY_FILE"' EXIT
|
trap 'rm -f "$KEY_FILE"' EXIT
|
||||||
|
|
||||||
@@ -50,5 +65,5 @@ jobs:
|
|||||||
|
|
||||||
rsync -az --delete \
|
rsync -az --delete \
|
||||||
-e "ssh -i $KEY_FILE -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts" \
|
-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