Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: build and deploy
name: prod CI/CD

on:
push:
branches:
- dev
- main
jobs:
build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/staging_build_and_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: staging CI/CD

on:
push:
branches:
- staging
jobs:
build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
environment: staging_environment
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
file: ./Dockerfile
build-args: |
REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/staging-bbbs-frontend:latest
deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_docker_hub
environment: staging_environment
steps:
-
name: execute remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ${{ secrets.SERVER_FOLDER }}
git checkout ${{ secrets.BRANCH }}
export COMPOSE_FILE=${{ secrets.COMPOSE_FILE }}
docker pull ${{ secrets.DOCKER_USERNAME }}/staging-bbbs-frontend:latest
docker-compose down
docker-compose up -d --build