50 lines
1.9 KiB
YAML
50 lines
1.9 KiB
YAML
name: Deploy eolas-api
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Deploy to VPS
|
|
run: |
|
|
echo "⚡ INFO Installing rsync"
|
|
apt-get update && apt-get install -y rsync
|
|
|
|
echo "⚡ INFO Retrieving SSH key for deploy user"
|
|
echo "${{ secrets.VPS_DEPLOY_USER_SSH_KEY }}" > /tmp/ssh_key
|
|
chmod 600 /tmp/ssh_key
|
|
|
|
echo "⚡ INFO Stopping service on VPS"
|
|
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no ${{vars.VPS_DEPLOY_USER}} sudo /usr/bin/systemctl stop eolas-api.service
|
|
|
|
echo "⚡ INFO Copy updated sourcefile files via rsync"
|
|
rsync -avz --delete --inplace --exclude='.env' -e "ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no" ./ ${{ vars.VPS_DEPLOY_USER }}:/var/www/eolas-api/
|
|
|
|
echo "⚡ INFO Run npm install on VPS"
|
|
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no ${{vars.VPS_DEPLOY_USER}} "bash -l -c 'source ~/.nvm/nvm.sh && cd /var/www/eolas-api && npm install --omit=dev'"
|
|
|
|
echo "⚡ INFO Restarting service"
|
|
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no ${{vars.VPS_DEPLOY_USER}} "bash -l -c 'sudo /usr/bin/systemctl daemon-reload && sudo /usr/bin/systemctl start eolas-api.service'"
|
|
|
|
rm /tmp/ssh_key
|
|
|
|
- name: Notify success
|
|
if: success()
|
|
run: |
|
|
curl -u thomas:${{ secrets.NTFY_PASSWORD }} \
|
|
-H "Tags: Forgejo Runner" \
|
|
-d "🟩 eolas-api successfully deployed" \
|
|
https://ntfy.systemsobscure.net/eolas
|
|
|
|
- name: Notify failure
|
|
if: failure()
|
|
run: |
|
|
curl -u thomas:${{ secrets.NTFY_PASSWORD }} \
|
|
-H "Tags: Forgejo Runner" \
|
|
-d "🟥 An error occurred deploying eolas-api. See Forgejo Action logs." \
|
|
https://ntfy.systemsobscure.net/eolas
|