Updated the workflow #9
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 Code | |
on: [push, pull_request] | |
jobs: | |
test: | |
environment: | |
name: testing | |
env: | |
TF_MODEL_EPOCHS: ${{vars.TF_MODEL_EPOCHS}} | |
IMAGE_SIZE_X: ${{vars.IMAGE_SIZE_X}} | |
IMAGE_SIZE_Y: ${{vars.IMAGE_SIZE_Y}} | |
# services: | |
# postgres: | |
# image: postgres | |
# env: | |
# POSTGRES_PASSWORD: ${{secrets.DATABASE_PASSWORD}} | |
# POSTGRES_DB: ${{secrets.DATABASE_NAME}}_test | |
# ports: | |
# - 5432:5432 | |
# options: >- | |
# --health-cmd pg_isready | |
# --health-interval 10s | |
# --health-timeout 5s | |
# --health-retries 5 | |
runs-on: ubuntu-latest | |
steps: | |
- name: pulling git repo | |
uses: actions/checkout@v2 | |
- name: Install packages | |
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-glx | |
- name: Install python version 3.12 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.12" | |
- name: update pip | |
run: python -m pip install --upgrade pip | |
- name: install | |
run: make install | |
- name: test | |
run: make test | |
# - name: Login to Docker Hub | |
# uses: docker/login-action@v1 | |
# with: | |
# username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
# - name: Set up Docker Buildx | |
# id: buildx | |
# uses: docker/setup-buildx-action@v1 | |
# - name: Build and push | |
# id: docker_build | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: ./ | |
# file: ./Dockerfile | |
# builder: ${{ steps.buildx.outputs.name }} | |
# push: true | |
# tags: ${{ secrets.DOCKER_HUB_USERNAME }}/fastapi:latest | |
# cache-from: type=local,src=/tmp/.buildx-cache | |
# cache-to: type=local,dest=/tmp/.buildx-cache | |
# - name: Image digest | |
# run: echo ${{ steps.docker_build.outputs.digest }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [test] | |
environment: | |
name: production | |
steps: | |
- name: pulling git repo | |
uses: actions/checkout@v2 | |
- name: install | |
run: make install | |
- name: build | |
run: make build | |
- name: SCP repo to remote server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.PROD_HOST }} | |
username: ${{ secrets.PROD_USERNAME }} | |
password: ${{ secrets.PROD_PASSWORD }} | |
source: "./*" | |
target: "/root/image-classification" | |
- name: deploy to ubuntu server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{secrets.PROD_HOST}} | |
username: ${{secrets.PROD_USERNAME}} | |
password: ${{secrets.PROD_PASSWORD}} | |
script: | | |
echo ${{secrets.PROD_PASSWORD}} | sudo -S systemctl restart image-classification |