1
1
name : Deploy Preview
2
2
3
- on :
3
+ permissions : {}
4
+
5
+ on :
4
6
pull_request :
5
7
6
8
env :
12
14
13
15
jobs :
14
16
deploy :
15
- permissions :
17
+ permissions :
16
18
pull-requests : write
17
19
# Secrets aren't available for Dependabot PR (because the updated
18
20
# dependencies might abuse them), so they don't have enough rights to
@@ -22,12 +24,14 @@ jobs:
22
24
steps :
23
25
- name : Checkout
24
26
uses : actions/checkout@v4
25
-
27
+ with :
28
+ persist-credentials : false
29
+
26
30
- name : Setup Cloud SDK
27
31
uses : ' google-github-actions/auth@v2'
28
32
with :
29
33
credentials_json : ' ${{ secrets.GCP_SA_KEY }}'
30
-
34
+
31
35
- name : Use gcloud CLI
32
36
run : gcloud info
33
37
@@ -37,19 +41,19 @@ jobs:
37
41
continue-on-error : true
38
42
run : |
39
43
gcloud sql instances create ${{ env.SERVICE }}-${{ env.TAG }} --tier=db-f1-micro --region=${{ env.REGION }} --database-version=POSTGRES_15 --edition=enterprise
40
- gcloud sql users set-password postgres --host=% --instance ${{ env.SERVICE }}-${{ env.TAG }} --password postgres
44
+ gcloud sql users set-password postgres --host=% --instance ${{ env.SERVICE }}-${{ env.TAG }} --password postgres
41
45
gcloud sql databases create blurts --instance=${{ env.SERVICE }}-${{ env.TAG }}
42
46
gcloud sql databases list --instance=${{ env.SERVICE }}-${{ env.TAG }}
43
47
gcloud sql instances list
44
-
48
+
45
49
- name : Authorize Docker push
46
50
run : gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
47
51
48
52
- name : Build and Push Container
49
53
run : |-
50
54
docker build -t ${{env.REGION}}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }} -f './Dockerfile.cloudrun' .
51
55
docker push ${{env.REGION}}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}
52
-
56
+
53
57
- name : Deploy to Cloud Run
54
58
id : deploy
55
59
uses : google-github-actions/deploy-cloudrun@v2
79
83
DB_USER=postgres
80
84
DB_PASSWORD=postgres
81
85
CLOUD_SQL_CONNECTION_NAME=${{ env.PROJECT_ID }}:${{env.REGION}}:${{ env.SERVICE }}-${{ env.TAG }}
82
- DATABASE_URL= postgres://postgres:postgres@localhost:5432/blurts
86
+ DATABASE_URL= postgres://postgres:postgres@localhost:5432/blurts
83
87
84
88
- name : Comment on Pull Request
85
89
uses : thollander/actions-comment-pull-request@v3
89
93
Preview URL :rocket: : ${{ steps.deploy.outputs.url }}
90
94
comment-tag : preview_url
91
95
create-if-not-exists : true
92
-
0 commit comments