update deployment pipeline
All checks were successful
deploy / build-and-deploy (/opt/website, website) (push) Successful in 28s
deploy / build-and-deploy (/opt/website-test, website-test) (push) Successful in 14s

This commit is contained in:
2025-06-09 15:15:44 +02:00
parent 564aa9eeda
commit 11b0ee4083

View File

@ -6,10 +6,25 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- dir: /opt/website
service: website
- dir: /opt/website-test
service: website-test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: |
dist/
node_modules/
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm i
@ -21,6 +36,8 @@ jobs:
HOST: ${{ secrets.SSH_HOST}}
USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
DIRECTORY: ${{ matrix.dir }}
SERVICE: ${{ matrix.service }}
run: |
mkdir -p "$HOME/.ssh" && touch "$HOME/.ssh/known_hosts"
echo "$SSH_KEY" > "$HOME/.ssh/deploy_key"
@ -29,6 +46,6 @@ jobs:
ssh-add "$HOME/.ssh/deploy_key"
ssh-keyscan -t rsa "$HOST" >> "$HOME/.ssh/known_hosts"
ssh -o StrictHostKeyChecking=no $USER@$HOST "rm -r /opt/website; mkdir -p /opt/website"
scp -r -o StrictHostKeyChecking=no $(ls -d -1 dist/*) $(ls package*) $USER@$HOST:/opt/website
ssh -o StrictHostKeyChecking=no $USER@$HOST "cd /opt/website; npm i --omit=dev; systemctl restart website"
ssh -o StrictHostKeyChecking=no $USER@$HOST "rm -r $DIRECTORY; mkdir -p $DIRECTORY"
scp -r -o StrictHostKeyChecking=no $(ls -d -1 dist/*) $(ls package*) $USER@$HOST:$DIRECTORY
ssh -o StrictHostKeyChecking=no $USER@$HOST "cd $DIRECTORY; npm i --omit=dev; systemctl restart $SERVICE"