-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (52 loc) · 1.8 KB
/
Copy pathcloud-run.yml
File metadata and controls
64 lines (52 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This workflow will build and deploy using Cloud Run.
name: Cloud Run Continuous Deployment
on:
push:
branches: 'main'
release:
types: [published]
env:
PROJECT_ID: 'diegoperez16techx25'
SERVICE_NAME: 'ise-genai-d5'
SERVICE_REGION: 'us-central1'
SERVICE_ACCOUNT: '1085648047398-compute@developer.gserviceaccount.com'
WORKLOAD_IDENTITY_PROVIDER: 'projects/1085648047398/locations/global/workloadIdentityPools/github/providers/project-repo'
jobs:
py-checks:
uses: ./.github/workflows/python-checks.yml
build-deploy:
name: 'Build and deploy using Cloud Run'
runs-on: ubuntu-latest
needs: py-checks
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: 'actions/checkout@v4'
# Authorize GitHub to connect to your service account
- uses: 'google-github-actions/auth@v2'
with:
project_id: '${{ env.PROJECT_ID }}'
workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER}}'
service_account: '${{ env.SERVICE_ACCOUNT }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
project_id: '${{ env.PROJECT_ID }}'
version: '>= 363.0.0'
- name: 'Configure docker for GCP'
run: 'gcloud auth configure-docker'
- name: 'Build and push Docker image'
uses: 'docker/build-push-action@v5'
with:
context: .
push: true
tags: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}'
- id: 'Deploy'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
service: '${{ env.SERVICE_NAME }}'
image: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:latest'
region: '${{ env.SERVICE_REGION }}'
- name: 'Display deployed app URL'
run: 'curl "${{ steps.deploy.outputs.url }}"'