Merge pull request #18 from Mexidense/refactor/remove-vercel-analytics #4
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 UML2Code with Google Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
env: | |
CLOUD_RUN_PROJECT_ID: ${{ secrets.CLOUD_RUN_PROJECT_NAME }} | |
CLOUD_RUN_REGION: europe-southwest1 | |
REPO_NAME: uml2code | |
jobs: | |
build-and-deploy: | |
name: Setup, Build, and Deploy | |
environment: production | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: google-github-actions/setup-gcloud@v0.2.0 | |
with: | |
project_id: ${{ secrets.CLOUD_RUN_PROJECT_NAME }} | |
service_account_key: ${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }} | |
service_account_email: ${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT_EMAIL }} | |
- name: Enable the necessary APIs and enable docker auth | |
run: |- | |
gcloud services enable containerregistry.googleapis.com | |
gcloud services enable run.googleapis.com | |
gcloud --quiet auth configure-docker | |
- name: Build and tag image | |
run: |- | |
docker build . --tag "gcr.io/$CLOUD_RUN_PROJECT_ID/$REPO_NAME:$GITHUB_SHA" | |
- name: Push image to GCR | |
run: |- | |
docker push gcr.io/$CLOUD_RUN_PROJECT_ID/$REPO_NAME:$GITHUB_SHA | |
- name: Deploy | |
run: |- | |
gcloud components install beta --quiet | |
gcloud beta run deploy $REPO_NAME --image gcr.io/$CLOUD_RUN_PROJECT_ID/$REPO_NAME:$GITHUB_SHA \ | |
--project $CLOUD_RUN_PROJECT_ID \ | |
--platform managed \ | |
--region $CLOUD_RUN_REGION \ | |
--allow-unauthenticated \ | |
--quiet \ | |
--set-env-vars OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} |