update #5
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 Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Lint code | |
run: | | |
pip install flake8 | |
flake8 . | |
- name: Build Docker image for FastAPI | |
run: docker build -t fastapi-bert-predictor -f Dockerfile . | |
- name: Build Docker image for TensorFlow Serving | |
run: docker build -t bert-election2020-serving -f Dockerfile-tf-serving . | |
- name: Log in to Google Cloud | |
uses: google-github-actions/auth@v0 | |
with: | |
credentials_json: ${{ secrets.GOOGLE_CLOUD_CREDENTIALS }} | |
- name: Configure Google Cloud | |
run: | | |
gcloud config set project ${{ secrets.GCP_PROJECT_ID }} | |
gcloud auth configure-docker | |
- name: Push Docker images to Google Container Registry | |
run: | | |
docker tag fastapi-bert-predictor gcr.io/${{ secrets.GCP_PROJECT_ID }}/fastapi-bert-predictor:latest | |
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/fastapi-bert-predictor:latest | |
docker tag bert-election2020-serving gcr.io/${{ secrets.GCP_PROJECT_ID }}/bert-election2020-serving:latest | |
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/bert-election2020-serving:latest | |
- name: Deploy to Google Kubernetes Engine | |
run: | | |
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER_NAME }} --zone ${{ secrets.GKE_ZONE }} | |
kubectl apply -f k8s/deployment.yml | |
kubectl apply -f k8s/service.yml |