rebuild api image on deployment #44
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: CI / CD | |
on: | |
push: | |
paths: | |
- 'api/**' | |
- '.github/workflows/cicd.yml' | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and run tests | |
run: docker-compose up --build --exit-code-from test test | |
- name: Clean up | |
run: docker-compose down | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
#if: github.ref == 'refs/heads/develop' | |
steps: | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd amazonia-360 | |
git pull --rebase | |
sudo docker-compose down | |
sudo docker-compose up -d api --build --exit-code-from api | |
health-check: | |
name: Health Check | |
runs-on: ubuntu-latest | |
needs: deploy | |
#if: github.ref == 'refs/heads/develop' | |
steps: | |
- name: URL Health Check | |
uses: Jtalk/url-health-check-action@v4 | |
with: | |
url: ${{ secrets.HEALTHCHECK }} | |
retries: 5 | |
wait: 10 | |