-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (125 loc) · 3.83 KB
/
gae-deploy.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
name: GAE Deploy
on:
push:
branches: [ main ]
pull_request:
types: [opened, reopened, synchronize]
branches: [ main ]
workflow_dispatch:
jobs:
go-test:
name: Go Test
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Get dependencies
run: go get -v -t -d ./...
- name: Test
run: go test -v -cover -race
js-test:
name: JavaScript Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm install
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Export Test
run: npm run export
gae-deploy-dev:
name: GAE Deploy DEV
if: github.event.pull_request.head.ref == 'develop'
needs: [go-test, js-test]
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm install
- name: Export assets
run: npm run export
- name: Auth GCP
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Recover App Secrets DEV
run: 'echo "$APP_SECRETS_DEV_YAML" > secrets.dev.yaml'
shell: bash
env:
APP_SECRETS_DEV_YAML: ${{ secrets.APP_SECRETS_DEV_YAML }}
- name: Deploy DEV
run: gcloud app deploy ./app.dev.yaml --quiet --no-cache
gae-deploy-prod:
name: GAE Deploy PROD
if: github.ref == 'refs/heads/main'
needs: [go-test, js-test]
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm install
- name: Export assets
run: npm run export
- name: Auth GCP
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Recover App Secrets PROD
run: 'echo "$APP_SECRETS_PROD_YAML" > secrets.yaml'
shell: bash
env:
APP_SECRETS_PROD_YAML: ${{ secrets.APP_SECRETS_PROD_YAML }}
- name: Deploy PROD
run: gcloud app deploy ./app.yaml --quiet --no-cache
- name: Deploy CRON
run: gcloud app deploy ./cron.yaml --quiet --no-cache
- name: Announce on Slack
run: |
PREVIOUS_MERGE_COMMIT=`git log --merges --max-count=1 --pretty="%H" --skip=1`
echo "[INFO] PREVIOUS_MERGE_COMMIT ${PREVIOUS_MERGE_COMMIT}"
COMMITS_INCLUDED=`git log --no-merges --pretty="・ %s" $PREVIOUS_MERGE_COMMIT..`
echo "[INFO] COMMITS_INCLUDED ${COMMITS_INCLUDED}"
curl -XPOST \
-d "{
\"channel\": \"tech\",
\"text\": \"あたらしいバージョンがリリースされました! :tada:\n${COMMITS_INCLUDED}\ngithub.com/${GITHUB_REPOSITORY}/compare/${PREVIOUS_MERGE_COMMIT}..main\"
}" \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_USER_OAUTH_TOKEN }}" \
-H "Content-Type: application/json" \
https://slack.com/api/chat.postMessage