Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request - CI/CD Part 2 Pipeline to Sandbox- Digital Dreamers #101

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
61 changes: 61 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI/CD Pipeline

on:
pull_request:
branches:
- staging
types:
- closed


jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIAL }}

- name: Set Up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: '>= 363.0.0'

- name: Configure Docker to Authenticate with GCR
run: gcloud auth configure-docker

- name: Set Environment Variables
id: secrets
run: |
echo "ENV_TYPE=$(gcloud secrets versions access latest --secret=ENV_TYPE)" >> $GITHUB_ENV
echo "GCP_PROJECT_ID=$(gcloud secrets versions access latest --secret=GCP_PROJECT_ID)" >> $GITHUB_ENV

- name: Build Docker Image
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
IMAGE_NAME=gcr.io/${{ env.GCP_PROJECT_ID }}/my-app:${COMMIT_HASH}
docker build -t ${IMAGE_NAME} .
docker tag ${IMAGE_NAME} gcr.io/${{ env.GCP_PROJECT_ID }}/my-app:latest

- name: Push Docker Image to GCR
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
docker push gcr.io/${{ env.GCP_PROJECT_ID }}/my-app:${COMMIT_HASH}
docker push gcr.io/${{ env.GCP_PROJECT_ID }}/my-app:latest

- name: Deploy to Google Cloud Run
run: |
gcloud run deploy my-app \
--image gcr.io/${{ env.GCP_PROJECT_ID }}/my-app:latest \
--port 8000 \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars "ENV=${{ env.ENV_TYPE }}" \
--project ${{ env.GCP_PROJECT_ID }}

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fastapi
fastapi[standard]
uvicorn[standard]
langchain
langchain-core
Expand All @@ -15,4 +15,4 @@ pypdf
fpdf
youtube-transcript-api
pytube
python-dotenv
python-dotenv