Merge pull request #784 from hngprojects/dev #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: Staging Deployment | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- staging | |
jobs: | |
build-and-push: | |
if: github.event.repository.fork == false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
run: docker build -t nestjs_staging:green . | |
- name: Save and compress Docker image | |
run: | | |
docker save nestjs_staging:green | gzip > nestjs_staging.tar.gz | |
- name: Copy image to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
source: 'nestjs_staging.tar.gz' | |
target: '/tmp' | |
deploy: | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
environment: | |
name: 'staging' | |
url: ${{ vars.URL }} | |
steps: | |
- name: Deploy on server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
cd ~/hng_boilerplate_nestjs | |
./deploy.sh staging |