v1.0.2-hotfix2 update package.json #24
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
# This workflow build and push a Docker container to Google Artifact Registry | |
# and deploy it on Cloud Run when a PR to the `release` branch is made. | |
name: 'Build and Deploy UAT to Cloud Run' | |
on: | |
pull_request: | |
branches: | |
- release | |
types: [opened, edited, synchronize] # PR opened, edited(PR title, etc), new commits are pushed. | |
env: | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
REGION: ${{ secrets.REGION_LOC_1 }} | |
SERVICE: ${{ secrets.SERVICE }} | |
IMAGE_NAME: 'map-dragon_img' | |
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }} | |
jobs: | |
deploy: | |
runs-on: 'ubuntu-latest' | |
if: github.event.pull_request.base.ref == 'release' | |
environment: | |
name: uat | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: 'Checkout' | |
uses: 'actions/checkout@v4' | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: '${{ env.GCP_CREDENTIALS }}' | |
- name: Extract Version from PR Title # Assumes PR title contains the tag. ex v0.0.0 or v0.0.0-abc | |
run: | | |
VERSION=$(echo "${{ github.event.pull_request.title }}" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+\(-[a-zA-Z]*\)\?') | |
echo "Extracted Version: ${VERSION}" | |
- name: Generate .env.uat file | |
run: | | |
echo "VITE_CLIENT_ID = ${{ secrets.VITE_CLIENT_ID }}" > .env.uat | |
echo "VITE_SEARCH_ENDPOINT = ${{ secrets.VITE_SEARCH_ENDPOINT }}" >> .env.uat | |
echo "VITE_VOCAB_ENDPOINT= ${{ secrets.VITE_VOCAB_ENDPOINT }}" >> .env.uat | |
echo "VITE_MAPDRAGON_VERSION=${VERSION}" >> .env.uat | |
- name: 'Docker Auth' | |
run: |- | |
gcloud auth configure-docker '${{ env.REGION }}-docker.pkg.dev' | |
- name: 'Build Docker Image' # New step to build the image | |
run: |- | |
DOCKER_TAG="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
docker build -t "${DOCKER_TAG}" --build-arg ENV=uat . | |
- name: 'Push Docker Image' | |
run: |- | |
DOCKER_TAG="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
docker push "${DOCKER_TAG}" | |
- name: 'Deploy to Cloud Run' | |
uses: 'google-github-actions/deploy-cloudrun@v2' | |
with: | |
service: '${{ env.SERVICE }}' | |
region: '${{ env.REGION }}' | |
image: "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
env_vars: VERSION=${VERSION} |