-
Notifications
You must be signed in to change notification settings - Fork 2
118 lines (104 loc) · 3.82 KB
/
Copy pathdeploy.yaml
File metadata and controls
118 lines (104 loc) · 3.82 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Deploy
on:
push:
branches: ["master"]
tags: ["v*.*.*"]
env:
IMAGE_NAME: grumma
PROJECT_ID: gramma-400100
SERVICE: grumma-oss
REGION: asia-northeast1
REGISTRY: asia-northeast1-docker.pkg.dev/gramma-400100/grumma
PUBLIC_URL: https://grumma.org
DATABASE_URL: ${{secrets.DATABASE_URL}}
PUBLIC_REAL_TIME_CONTENT_UPDATE: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
outputs:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 #v4.1.2
with:
cosign-release: "v2.2.4"
- name: Google Auth
id: auth
uses: "google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093"
with:
token_format: "access_token"
workload_identity_provider: "${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}"
service_account: ${{secrets.SERVICE_ACCOUNT}}
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
registry: "${{ env.REGION }}-docker.pkg.dev"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=long,prefix=
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the published Docker image
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
migrate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b
with:
cache: true
- run: pnpm exec drizzle-kit migrate
deploy:
needs: [publish, migrate]
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Google Auth
id: auth
uses: "google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093"
with:
project_id: "${{ env.PROJECT_ID }}"
workload_identity_provider: "${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}"
- name: Create Service declaration
run: |-
export IMAGE="${{ needs.publish.outputs.image }}"
export SERVICE="${{ env.SERVICE }}"
export PUBLIC_REAL_TIME_CONTENT_UPDATE=${{env.PUBLIC_REAL_TIME_CONTENT_UPDATE}}
envsubst < gcloud/service.template.yaml > service.yaml
cat service.yaml
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@2028e2d7d30a78c6910e0632e48dd561b064884d
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
metadata: "service.yaml"
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}