Update main.yml #13
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: build-push-deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
run: docker build \ | |
--build-arg JWT_SECRET=${{ secrets.JWT_SECRET }} \ | |
--build-arg MONGO_URI=${{ secrets.MONGO_URI }} \ | |
--build-arg PORT=${{ vars.PORT }} \ | |
-t kingitsolutionsteam/nawwa-test:${{ github.sha }} . | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker image to Docker Hub | |
run: docker push kingitsolutionsteam/nawwa-test:${{ github.sha }} | |
deploy: | |
runs-on: nawwa-runner | |
needs: build-and-push | |
steps: | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Pull Docker image | |
run: sudo docker pull kingitsolutionsteam/nawwa-test:${{ github.sha }} | |
- name: Deploy Docker image | |
run: sudo docker run -d -p ${{ vars.PORT }}:9005 kingitsolutionsteam/nawwa-test:${{ github.sha }} |