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 and Deploy on digital ocean | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build_main_api: | |
name: Build Main API [.net] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Log in Docker HUB | |
uses: docker/login-action@v1 | |
with: | |
username: leroman | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build docker | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./backend/Diary | |
file: ./backend/Diary/Dockerfile | |
push: true | |
tags: leroman/diary_api | |
build_ng: | |
name: Build Angular | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Log in Docker HUB | |
uses: docker/login-action@v1 | |
with: | |
username: leroman | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build docker | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./frontend | |
file: ./frontend/Dockerfile | |
push: true | |
tags: leroman/diary_ng | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [build_main_api, build_ng] | |
steps: | |
- name: Login via SSH and call docker-compose | |
uses: appleboy/ssh-action@v0.1.3 | |
with: | |
host: 165.232.75.90 | |
username: root | |
password: ${{ secrets.DIGITAL_OCEAN_DROPLET_PASSWORD }} | |
script: | | |
cd /home | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" > .env | |
echo "ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}" >> .env | |
echo "JWT_KEY=${{ secrets.JWT_KEY }}" >> .env | |
echo "MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }}" >> .env | |
echo "MAIL_USERNAME=${{ secrets.MAIL_USERNAME }}" >> .env | |
docker-compose down | |
docker-compose pull | |
docker-compose up --detach |