Merge pull request #219 from a0uda/PostAndCommentFeature #236
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
# CD Backend | |
name: CD BE | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build_dev_test: | |
name: Build Backend For Dev files | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build Backend For Dev files | |
run: | | |
docker build -t dev-backend -f Dockerfile.dev . | |
- name: Run Backend For Testing Dev files | |
run: | | |
docker run --rm dev-backend | |
build_push_docker: | |
name: Build Backend For Prod files and push to docker | |
runs-on: ubuntu-latest | |
needs: build_dev_test | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build Backend For Prod files | |
run: | | |
docker build -t aoudaa/dkr-backend:latest . | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker Backend image | |
run: | | |
docker push aoudaa/dkr-backend:latest | |
deploy: | |
name: Deploy Backend For Prod files | |
runs-on: ubuntu-latest | |
needs: build_push_docker | |
steps: | |
- name: ssh into vm and run the script | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd ~/docker | |
sh deployBE.sh |