Skip to content

Some changes (#3)

Some changes (#3) #1

Workflow file for this run

name: Continuous Deployment Workflow
# This workflow is triggered whenever commits are pushed to the main branch
on:
push:
branches:
- 'main'
paths:
- 'web/**'
workflow_dispatch:
defaults:
run:
shell: bash
# Define the working directory for all run steps in the workflow
working-directory: ./web
jobs:
# ======================================================
# Deploy the main branch to staging
#
# It's important to test the main branch in staging
# before going to production with it.
# ======================================================
deploy_staging:
environment: staging
name: 'Deploy to staging'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: 'Checkout repository'
- uses: burnett01/rsync-deployments@23a557dceb19f9bb960ef40cf75cab5e9b37ec1f
name: 'Deploy to staging'
with:
switches: -avzr --delete
path: ./web
remote_path: /var/app
remote_host: ${{ secrets.HOSTNAME }}
remote_user: ${{ secrets.REMOTE_USER }}
remote_key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: JimCronqvist/action-ssh@7737f1192ddd8376686e9d6354dea44592c942bf
name: Execute SSH commmands on remote server
with:
hosts: '${{ secrets.REMOTE_USER }}@${{ secrets.HOSTNAME }}'
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
command: |
cd /var/app/web
npm ci
pm2 start /var/app/web/bin/www || pm2 restart /var/app/web/bin/www
sudo service nginx restart
# ======================================================
# Deploy the main branch to production
#
# This job will require the `deploy_staging` job to
# run and complete successfully first!
#
# WARNING: this job will sync all the files that are
# in the folder ./web/ to the production server
# while removing all the files that are already
# in the production server!
# ======================================================
deploy_production:
environment: production
name: 'Deploy to production'
runs-on: ubuntu-latest
needs: deploy_staging
steps:
- uses: actions/checkout@v2
name: 'Checkout repository'
- uses: burnett01/rsync-deployments@23a557dceb19f9bb960ef40cf75cab5e9b37ec1f
name: 'Deploy to production'
with:
switches: -avzr --delete
path: ./web
remote_path: /var/app
remote_host: ${{ secrets.HOSTNAME }}
remote_user: ${{ secrets.REMOTE_USER }}
remote_key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: JimCronqvist/action-ssh@7737f1192ddd8376686e9d6354dea44592c942bf
name: Execute SSH commmands on remote server
with:
hosts: '${{ secrets.REMOTE_USER }}@${{ secrets.HOSTNAME }}'
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
command: |
cd /var/app/web
npm ci
pm2 start /var/app/web/bin/www || pm2 restart /var/app/web/bin/www
sudo service nginx restart