Skip to content

Merge pull request #16 from Mexidense/feat/add-google-cloud-ci-cd #2

Merge pull request #16 from Mexidense/feat/add-google-cloud-ci-cd

Merge pull request #16 from Mexidense/feat/add-google-cloud-ci-cd #2

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