Feat: Added booking confirmation + availability checking #20
This file contains hidden or 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: Deploy to Cloud Run Job | |
| on: | |
| push: | |
| branches: [main, master] # Triggers on push to main/master | |
| workflow_dispatch: # Allows manual triggering | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| REGION: ${{ secrets.GCP_REGION }} | |
| JOB_NAME: ${{ secrets.JOB_NAME }} | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| project_id: ${{ secrets.GCP_PROJECT_ID }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker | |
| - name: Build and push Docker image | |
| run: | | |
| # Build the image | |
| docker build -t gcr.io/$PROJECT_ID/$JOB_NAME:$GITHUB_SHA . | |
| docker build -t gcr.io/$PROJECT_ID/$JOB_NAME:latest . | |
| # Push the images | |
| docker push gcr.io/$PROJECT_ID/$JOB_NAME:$GITHUB_SHA | |
| docker push gcr.io/$PROJECT_ID/$JOB_NAME:latest | |
| - name: Deploy to Cloud Run Job | |
| run: | | |
| export CUSTOM_SA="[email protected]" | |
| # Check if job exists | |
| if gcloud run jobs describe $JOB_NAME --region=$REGION &>/dev/null; then | |
| echo "Updating existing job..." | |
| gcloud run jobs update $JOB_NAME \ | |
| --image=gcr.io/$PROJECT_ID/$JOB_NAME:$GITHUB_SHA \ | |
| --region=$REGION \ | |
| --task-timeout=1800 \ | |
| --memory=1Gi \ | |
| --cpu=1 \ | |
| --set-env-vars=GOOGLE_CLOUD_PROJECT=$PROJECT_ID | |
| else | |
| echo "Creating new job..." | |
| gcloud run jobs create $JOB_NAME \ | |
| --image=gcr.io/$PROJECT_ID/$JOB_NAME:$GITHUB_SHA \ | |
| --region=$REGION \ | |
| --task-timeout=1800 \ | |
| --memory=1Gi \ | |
| --cpu=1 \ | |
| --set-env-vars=GOOGLE_CLOUD_PROJECT=$PROJECT_ID | |
| fi | |
| - name: Test deployment | |
| run: | | |
| echo "Job deployed successfully!" | |
| echo "You can execute the job manually with:" | |
| echo "gcloud run jobs execute $JOB_NAME --region=$REGION" |