-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (164 loc) · 6.29 KB
/
deploy-cms-dev.yml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: ⭐️ Deploy CMS dev
on:
workflow_dispatch:
env:
GCS_DEST: gs://cms-plateau-dev
CMS_IMAGE_NAME: reearth/reearth-cms:rc
CMS_IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/plateau-view-3.0/reearth-cms:latest
CMS_IMAGE_NAME_GCP: asia-northeast1-docker.pkg.dev/reearth-plateau-dev/reearth-plateau/reearth-cms:latest
CMS_WEB_IMAGE_NAME: reearth/reearth-cms-web:rc
CMS_WEB_IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/plateau-view-3.0/reearth-cms-web:latest
CMS_WEB_IMAGE_NAME_GCP: asia-northeast1-docker.pkg.dev/reearth-plateau-dev/reearth-plateau/reearth-cms-web:latest
CMS_WORKER_IMAGE_NAME: reearth/reearth-cms-worker:rc
CMS_WORKER_IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/plateau-view-3.0/reearth-cms-worker:latest
CMS_WORKER_IMAGE_NAME_GCP: asia-northeast1-docker.pkg.dev/reearth-plateau-dev/reearth-plateau/reearth-cms-worker:latest
concurrency:
group: ${{ github.workflow }}
jobs:
deploy_web:
runs-on: ubuntu-latest
environment: dev
permissions:
contents: read
id-token: write
packages: write
if: github.event.repository.full_name == 'eukarya-inc/PLATEAU-VIEW-3.0'
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
run: gcloud auth configure-docker asia-northeast1-docker.pkg.dev --quiet
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker images
run: docker pull $CMS_WEB_IMAGE_NAME
- name: Tag docker images
run: |
docker tag $CMS_WEB_IMAGE_NAME $CMS_WEB_IMAGE_NAME_GHCR
docker tag $CMS_WEB_IMAGE_NAME $CMS_WEB_IMAGE_NAME_GCP
- name: Push docker images
run: |
docker push $CMS_WEB_IMAGE_NAME_GHCR
docker push $CMS_WEB_IMAGE_NAME_GCP
- name: Deploy
run: |
gcloud run deploy reearth-cms-web \
--image $CMS_WEB_IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet
env:
GCP_REGION: ${{ vars.GCP_REGION }}
# TODO: Remove after migrating to Cloud Run.
deploy_web_gcs:
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'eukarya-inc/PLATEAU-VIEW-3.0'
environment: dev
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Download CMS web
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{ steps.app-token.outputs.token }}
repo: reearth/reearth-cms
workflow: ci_web.yml
branch: release
name: reearth-cms-web
check_artifacts: true
search_artifacts: true
- name: Extract
run: tar -xvf reearth-cms-web.tar.gz
- name: Replace favicon / App name
env:
PLATEAU_FAVICON: https://cms.plateau.reearth.io/img/favicon.ico
APP_PATH: reearth-cms-web/index.html
APP_NAME: PLATEAU CMS
run: |
SOURCE=$(cat $APP_PATH)
SOURCE=${SOURCE/\/assets\/favicon*.ico/$PLATEAU_FAVICON}
SOURCE=${SOURCE/\<title\>*\<\/title\>/<title>$APP_NAME</title>}
echo $SOURCE > $APP_PATH
- name: Deploy
run: gsutil -m -h "Cache-Control:no-store" rsync -x "^reearth_config\\.json$" -dr reearth-cms-web/ ${{ env.GCS_DEST }}
- name: Pack web
run: |
rm reearth-cms-web.tar.gz
tar -zcvf reearth-cms-web.tar.gz reearth-cms-web
- name: Save as artifact
uses: actions/upload-artifact@v4
with:
name: reearth-cms-web
path: reearth-cms-web.tar.gz
deploy_server_worker:
runs-on: ubuntu-latest
environment: dev
permissions:
contents: read
id-token: write
packages: write
if: github.event.repository.full_name == 'eukarya-inc/PLATEAU-VIEW-3.0'
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
run: gcloud auth configure-docker asia-northeast1-docker.pkg.dev --quiet
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker images
run: docker pull $CMS_IMAGE_NAME && docker pull $CMS_WORKER_IMAGE_NAME
- name: Tag docker images
run: |
docker tag $CMS_IMAGE_NAME $CMS_IMAGE_NAME_GHCR && \
docker tag $CMS_IMAGE_NAME $CMS_IMAGE_NAME_GCP && \
docker tag $CMS_WORKER_IMAGE_NAME $CMS_WORKER_IMAGE_NAME_GHCR && \
docker tag $CMS_WORKER_IMAGE_NAME $CMS_WORKER_IMAGE_NAME_GCP
- name: Push docker images
run: |
docker push $CMS_IMAGE_NAME_GHCR && \
docker push $CMS_IMAGE_NAME_GCP && \
docker push $CMS_WORKER_IMAGE_NAME_GHCR && \
docker push $CMS_WORKER_IMAGE_NAME_GCP
- name: Deploy
run: |
gcloud run deploy reearth-cms-api \
--image $CMS_IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet
gcloud run deploy reearth-cms-worker \
--image $CMS_WORKER_IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet
env:
GCP_REGION: ${{ vars.GCP_REGION }}