Merge pull request #2 from niraj-khatiwada/bugfix.docker-setup-prod #1
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: prod-deployment | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: self-hosted | |
environment: production | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Executing remote command | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PRODUCTION_EC2_HOST }} | |
USERNAME: ${{ secrets.PRODUCTION_EC2_USERNAME }} | |
PORT: ${{ secrets.PRODUCTION_EC2_PORT }} | |
KEY: ${{ secrets.PRODUCTION_EC2_PRIVATESSHKEY }} | |
command_timeout: 20m | |
script_stop: true | |
script: | | |
cd ~/nestjs-boilerplate | |
git reset --hard HEAD | |
git pull origin main | |
docker build --tag nestjs-boilerplate-prod:latest . --no-cache | |
pnpm docker:prod:down | |
pnpm docker:prod:up | |
docker volume prune -f |