Skip to content

try again

try again #27

name: Deploy to Cloud Run on merge
on:
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "23"
- name: Install dependencies
run: npm install
- name: Run build
run: npm run build:prod
- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
export_default_credentials: true
- name: Login to Google Cloud
uses: google-github-actions/auth@v1
with:
create_credentials_file: true
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Build and Push to Google Container Registry
run: |
gcloud auth configure-docker
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/bookenzy-backend:latest \
--build-arg DATABASE_URL=${{ secrets.DATABASE_URL_PROD }} \
--build-arg BOOKENZY_JWT_SECRET=${{ secrets.JWT_SECRET_PROD }} .
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/bookenzy-backend:latest
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v2
with:
service: bookenzy-backend
image: gcr.io/${{ secrets.GCP_PROJECT_ID }}/bookenzy-backend:latest
project: ${{ secrets.GCP_PROJECT_ID }}
region: asia-south2
allow_unauthenticated: true
credentials_json: ${{ secrets.GCP_SA_KEY }}
set-env-vars: |
DATABASE_URL=${{ secrets.DATABASE_URL_PROD }},
BOOKENZY_JWT_SECRET=${{ secrets.JWT_SECRET_PROD }}