Skip to content

Commit

Permalink
chore: add deploy-prod action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
andirueckel committed Jun 5, 2024
1 parent f8b5689 commit cff4ca6
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: '⚠️‼️ deploy_prod → cms-mail-notification-backend.rundgang.udk-berlin.de'

on:
#push:
# branches: [ "main" ]
#pull_request:
# branches: [ "main" ]
workflow_dispatch:
inputs:
ref:
description: The branch, tag or SHA to checkout
required: true
default: 'main'

jobs:
deploy_prod:
runs-on: ubuntu-latest

env:
ssh_user: 'root'
ssh_host: 'cms-mail-notification-backend.rundgang.udk-berlin.de'
ssh_key: ${{ secrets.SSH_RUNDGANG_UDK_BERLIN_DE }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}

- run: mkdir -p ~/.ssh/
- run: echo "$ssh_key" > ~/.ssh/private.key
- run: chmod 600 ~/.ssh/private.key
- run: |
cat > ~/.ssh/config << EOF
Host remote
HostName $ssh_host
User $ssh_user
IdentityFile ~/.ssh/private.key
StrictHostKeyChecking no
EOF
- name: Run rsync to securely copy the build directory to the remote host
run: |
rsync \
--archive \
--compress \
--delete \
--exclude=.env \
--rsh="ssh -i ~/.ssh/private.key" \
--progress \
--verbose \
. \
remote:/opt/cms-mail-notification-backend/
#- run: ssh remote 'cd /opt/cms-mail-notification-backend/ && npm clean-install && npm run build --if-present && systemctl restart cms-mail-notification-backend.service'

- name: Stop the systemd service
run: ssh remote 'systemctl stop cms-mail-notification-backend.service'

- name: Install the nodejs project
run: ssh remote 'cd /opt/cms-mail-notification-backend/ && npm clean-install && npm run build --if-present'

- name: Start the systemd service
run: ssh remote 'systemctl start cms-mail-notification-backend.service'

0 comments on commit cff4ca6

Please sign in to comment.