Created
April 30, 2022 19:13
-
-
Save vaso991/ff75d07a5bd7e00079fee71083b0abb2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Deploy Nodejs App On Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
server: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install Server Modules | |
run: | | |
npm ci | |
npm install | |
env: | |
CI: true | |
- name: Copy file via scp | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
password: ${{ secrets.REMOTE_PASSWORD }} | |
port: 22 | |
source: "./*" | |
target: "/opt/app" | |
- name: Migrate db | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
password: ${{ secrets.REMOTE_PASSWORD }} | |
port: 22 | |
script: "cd /opt/app && npm run db:migrate" | |
- name: Restart pm2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
password: ${{ secrets.REMOTE_PASSWORD }} | |
port: 22 | |
script: pm2 restart app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment