Skip to content

Update README.md

Update README.md #1

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- main
- next
jobs:
build-and-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.GCP_SA_KEY }}
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
version: 'latest'
- name: Build and Push Docker image for App
run: |
gcloud builds submit --tag gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ vars.IMAGE_NAME }}:${{ github.sha }} .
- name: Deploy App to Cloud Run
run: |
gcloud run deploy ${{ vars.IMAGE_NAME }} \
--image gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ vars.IMAGE_NAME }}:${{ github.sha }} \
--platform managed --region ${{ vars.REGION }} \
--allow-unauthenticated \
--set-env-vars "^##^API_VERSION=${{ vars.API_VERSION }}##PROTOCOL=${{ vars.PROTOCOL }}##DOMAIN=${{ vars.DOMAIN }}##AVAILABLE_BUCKETS=${{ vars.AVAILABLE_BUCKETS }}"
- name: Map Custom Domain for Apps
run: |
set +e # Disable immediate exit on error
CREATE_OUTPUT=$(gcloud -q beta run integrations create --type=custom-domains --region=${{ vars.REGION }} --parameters='set-mapping=${{ vars.DOMAIN }}:${{ vars.IMAGE_NAME }}' 2>&1)
CREATE_STATUS=$?
set -e # Re-enable immediate exit on error
if [ $CREATE_STATUS -ne 0 ]; then
echo "Attempt to create domain mapping failed: $CREATE_OUTPUT"
if echo "$CREATE_OUTPUT" | grep -q "Integration with name \[custom-domains\] already exists"; then
echo "Domain already exists, attempting to update..."
gcloud -q beta run integrations update custom-domains --region=${{ vars.REGION }} --parameters='set-mapping=${{ vars.DOMAIN }}:${{ vars.IMAGE_NAME }}'
else
echo "Failed due to an unexpected reason. Exiting with status code $CREATE_STATUS"
exit $CREATE_STATUS
fi
else
echo "Domain mapping created successfully."
fi