Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DeployPipeline | |
on: | |
push: | |
branches: ["pipeline-dev"] | |
jobs: | |
deploy: | |
name: Build And Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Debug - List Files in Build Directory | |
run: ls -al ./ | |
- name: Copy build to EC2 | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_SSH_KEY }} | |
source: ./apps/ | |
target: /home/ubuntu/slash/ | |
overwrite: true | |
- name: SSH into EC2 and restart app | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_SSH_KEY }} | |
script: | | |
# Install nvm | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
# Install the latest version of Node.js | |
nvm install node | |
# Use the installed Node.js version | |
nvm use node | |
# Install pm2 globally | |
npm install -g pm2 | |
# Stop all pm2 services | |
pm2 stop all | |
# Landing | |
cd slash/apps/landing | |
# Install dependencies | |
npm install | |
# Stop and start your application using pm2 | |
pm2 restart all | |
pm2 stop slash_landing | |
pm2 start npm --name slash_landing -- start |