Skip to content

Commit

Permalink
Updated CD workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
im1ex committed Jul 2, 2024
1 parent d74138c commit 0fca95d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ on:
jobs:
Continuous-Delivery:
runs-on: ubuntu-latest
env:
SSH_HOST: ${{ secrets.DEPLOYMENT_HOST }}
SSH_USER: ${{ secrets.DEPLOYMENT_USER }}
SSH_KEY: ${{ secrets.DEPLOYMENT_KEY }}
SSH_PATH: ${{ secrets.DEPLOYMENT_PATH }}
steps:
- name: Configure SSH
env:
SSH_HOST: ${{ secrets.DEPLOYMENT_HOST }}
SSH_USER: ${{ secrets.DEPLOYMENT_USER }}
SSH_KEY: ${{ secrets.DEPLOYMENT_KEY }}
run: |
mkdir -p ~/.ssh/
cat >>~/.ssh/config <<END
Expand All @@ -33,12 +34,20 @@ jobs:
with:
node-version: '20.x'
cache: 'yarn'
- name: Install production dependencies into node_modules.new
run: |
yarn install --frozen-lockfile --production
mv node_modules node_modules.new
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build
run: yarn build

- name: Stop and delete service
run: ssh staging '$SSH_PATH/stop-service.sh && rm -rf $SSH_PATH/node_modules && rm -rf $SSH_PATH/dist'
- name: Copy dist to target host
env:
SSH_PATH: ${{ secrets.DEPLOYMENT_PATH }}
run: |
scp -r ./node_modules.new/ staging:$SSH_PATH/node_modules
scp -r ./dist staging:$SSH_PATH
- name: Start service
run: ssh staging '$SSH_PATH/start-service.sh'

0 comments on commit 0fca95d

Please sign in to comment.