Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit 1d7029f

Browse files
committed
add deploy github action
1 parent 423aac3 commit 1d7029f

File tree

5 files changed

+106
-28
lines changed

5 files changed

+106
-28
lines changed

Diff for: .github/workflows/_build.yaml

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ on:
66
type: string
77
service_account:
88
type: string
9-
gar_path:
9+
gar_repository:
10+
type: string
11+
gar_dst:
1012
type: string
1113
jobs:
1214
build:
1315
runs-on: ubuntu-latest
1416
permissions:
1517
contents: read
1618
packages: write
17-
actions: read
19+
id-token: write
1820
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
1923
- uses: google-github-actions/auth@v2
2024
with:
2125
workload_identity_provider: ${{ inputs.workload_identity_provider }}
@@ -24,13 +28,15 @@ jobs:
2428
uses: google-github-actions/setup-gcloud@v2
2529
- name: Set up Docker Buildx
2630
uses: docker/setup-buildx-action@v3
31+
- name: Log in to GAR
32+
run: gcloud auth configure-docker ${{ inputs.gar_repository }} --quiet
2733
- name: Build and push
2834
id: docker_build
2935
uses: docker/build-push-action@v5
3036
with:
31-
context: ./server
32-
file: ./server/Dockerfile.amd64
37+
context: ./
38+
file: ./Dockerfile.amd64
3339
platforms: linux/amd64
3440
push: true
3541
tags: |
36-
${{ inputs.gar_path }}:latest
42+
${{ inputs.gar_dst }}:latest

Diff for: .github/workflows/ci.yaml

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- add-ci
6+
- main
77
pull_request:
88
workflow_dispatch:
99
jobs:
@@ -12,22 +12,20 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v4
15-
1615
- name: Setup Node.js
1716
uses: actions/setup-node@v4
1817
with:
1918
node-version: '18.x'
20-
2119
- name: Dependencies
2220
run: npm ci
23-
2421
- name: Test and Build
2522
run: npm install -g pkg && npm test && npm run build
2623
build:
27-
uses: ./.github/workflows/_build.yml
24+
uses: ./.github/workflows/_build.yaml
2825
needs: ci
29-
if: ${{ !failure() && github.ref_name == 'add-ci' }}
26+
if: ${{ !failure() && github.ref_name == 'main' }}
3027
with:
3128
workload_identity_provider: projects/723082692741/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-provider
3229
service_account: reearth-dev-github-oidc@reearth-development.iam.gserviceaccount.com
33-
gcs_dst: gs://app.dev.reearth.io
30+
gar_repository: asia-northeast1-docker.pkg.dev
31+
gar_dst: asia-northeast1-docker.pkg.dev/reearth-development/eukarya/notion-proxy

Diff for: .github/workflows/deploy_dev.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy dev
2+
on:
3+
workflow_dispatch:
4+
env:
5+
IMAGE_NAME_GAR: asia-northeast1-docker.pkg.dev/reearth-development/eukarya/notion-proxy
6+
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/723082692741/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-provider
7+
GCP_SERVICE_ACCOUNT: reearth-dev-github-oidc@reearth-development.iam.gserviceaccount.com
8+
GCP_REGION: asia-northeast1
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
packages: read
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: google-github-actions/auth@v2
19+
with:
20+
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
21+
service_account: ${{ env.GCP_SERVICE_ACCOUNT }}
22+
- name: Set up Cloud SDK
23+
uses: google-github-actions/setup-gcloud@v2
24+
- name: Deploy to Cloud Run
25+
run: |
26+
gcloud run deploy reearth-help \
27+
--image $IMAGE_NAME \
28+
--region $GCP_REGION \
29+
--platform managed \
30+
--quiet
31+
env:
32+
IMAGE_NAME: ${{ env.IMAGE_NAME_GAR }}:latest

Diff for: .github/workflows/deploy_prod.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy prod
2+
on:
3+
workflow_dispatch:
4+
env:
5+
IMAGE_NAME_GAR: asia-northeast1-docker.pkg.dev/reearth/eukarya/notion-proxy
6+
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/950334725361/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-provider
7+
GCP_SERVICE_ACCOUNT: [email protected]
8+
GCP_REGION: asia-northeast1
9+
jobs:
10+
# TODO: Refactor with and env param
11+
build:
12+
uses: ./.github/workflows/_build.yaml
13+
with:
14+
workload_identity_provider: projects/950334725361/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-provider
15+
service_account: [email protected]
16+
gar_repository: asia-northeast1-docker.pkg.dev
17+
gar_dst: asia-northeast1-docker.pkg.dev/reearth/eukarya/notion-proxy
18+
deploy:
19+
runs-on: ubuntu-latest
20+
needs: build
21+
if: ${{ !failure() }}
22+
permissions:
23+
contents: read
24+
id-token: write
25+
packages: read
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: google-github-actions/auth@v2
29+
with:
30+
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
31+
service_account: ${{ env.GCP_SERVICE_ACCOUNT }}
32+
- name: Set up Cloud SDK
33+
uses: google-github-actions/setup-gcloud@v2
34+
- name: Deploy to Cloud Run
35+
run: |
36+
gcloud run deploy reearth-help \
37+
--image $IMAGE_NAME \
38+
--region $GCP_REGION \
39+
--platform managed \
40+
--quiet
41+
env:
42+
IMAGE_NAME: ${{ env.IMAGE_NAME_GAR }}:latest

0 commit comments

Comments
 (0)