Update Dockerfile #12
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: Create .env file | |
run: | | |
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env | |
echo MONGO_URI=${{ secrets.MONGO_URI }} >> .env | |
echo PORT=${{ vars.PORT }} >> .env | |
- name: List files in directory (debugging step) | |
run: ls -la | |
- name: Display .env file contents | |
run: cat .env | |
- name: Build Docker image | |
run: docker build -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 }} | |