update #27
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: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install . | |
- name: Run tests | |
run: | | |
export PYTHONPATH=$PYTHONPATH:$(pwd) | |
pytest tests/test_stock_prediction_api.py | |
build-and-push: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build the Docker image | |
run: docker build . --file Dockerfile --tag stock-prediction-api | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push | |
run: | | |
docker tag stock-prediction-api ${{ secrets.DOCKERHUB_USERNAME }}/stock-prediction-api:latest | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/stock-prediction-api:latest | |
deploy: | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
- name: Google Auth | |
id: "auth" | |
uses: "google-github-actions/auth@v1" | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: '${{ vars.WIF_PROVIDER }}' | |
service_account: '${{ vars.WIF_SERVICE_ACCOUNT }}' | |
- name: Push to GCloud | |
id: deploy | |
#uses: google-github-actions/deploy-cloudrun@v0 | |
run: |- | |
docker build -t "asia-south1-docker.pkg.dev/ecomscraper/images/stock-prediction-api:latest" ./ | |
docker push "asia-south1-docker.pkg.dev/ecomscraper/images/stock-prediction-api:latest" | |
- name: Deploy to Cloud Run | |
uses: google-github-actions/deploy-cloudrun@v0 | |
with: | |
image: "asia-south1-docker.pkg.dev/ecomscraper/images/stock-prediction-api:latest" | |
flags: | | |
--allow-unauthenticated | |
- name: Show Output | |
run: echo ${{ steps.deploy.outputs.url }} |