Another deploy test #3
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: Production Deployment [NextJS] | |
on: | |
pull_request: | |
branches: [production] | |
types : [closed] | |
push: | |
branches: [production] | |
workflow_dispatch: | |
jobs: | |
deploy: | |
if: (github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy using ssh | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PRODUCTION_HOST }} | |
username: ${{ secrets.PRODUCTION_USERNAME }} | |
key: ${{ secrets.PRODUCTION_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
cd ${{ vars.REPOSITORY_DIRECTORY }} | |
git pull origin production | |
git status | |
npm install --only=prod | |
npm build | |
npx pm2 restart ${{ vars.PM2_PROCESS }} | |
run: | | |
echo Pull request merged and deployed to Production |