fix bug in deploy action #4
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: sujalgoswami/boredtube:latest | |
target: production | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build-and-publish | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Remote SSH into VPS and deploy | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
sudo docker pull sujalgoswami/boredtube:latest | |
sudo docker stop boredtube || true | |
sudo docker rm boredtube || true | |
sudo docker run --restart=always -d --name boredtube -p 8001:8000 \ | |
-e PORT=8000 \ | |
-e MONGODB_URI=${{ secrets.MONGODB_URI }} \ | |
-e CORS_ORIGIN=${{ secrets.CORS_ORIGIN }} \ | |
-e ACCESS_TOKEN_SECRET=${{ secrets.ACCESS_TOKEN_SECRET }} \ | |
-e ACCESS_TOKEN_EXPIRY=${{ secrets.ACCESS_TOKEN_EXPIRY }} \ | |
-e REFRESH_TOKEN_SECRET=${{ secrets.REFRESH_TOKEN_SECRET }} \ | |
-e REFRESH_TOKEN_EXPIRY=${{ secrets.REFRESH_TOKEN_EXPIRY }} \ | |
-e CLOUDINARY_CLOUD_NAME=${{ secrets.CLOUDINARY_CLOUD_NAME }} \ | |
-e CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} \ | |
-e CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} \ | |
sujalgoswami/boredtube:latest |