-
Notifications
You must be signed in to change notification settings - Fork 4
199 lines (173 loc) · 5.63 KB
/
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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Deploy
on:
workflow_dispatch:
push:
branches:
- alpha
- beta
- legacy
- next
- production
- staging
paths:
- 'packages/**'
- 'apps/**'
env:
HUSKY: 0
jobs:
cache-and-install:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 18
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
filter-actions:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
dialtone: ${{ steps.filter.outputs.dialtone }}
dialtone-vue: ${{ steps.filter.outputs.dialtone-vue }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter actions by path
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dialtone:
- 'apps/dialtone-documentation/**'
- 'packages/**'
dialtone-vue:
- 'apps/dialtone-vue3-documentation/**'
- 'packages/**'
get-branch-name:
runs-on: ubuntu-latest
outputs:
current_branch: ${{ steps.branch-name.outputs.current_branch }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
check-dialpad-member:
runs-on: ubuntu-latest
steps:
# Will prevent the rest of the steps from running on fail
- name: Check if user is a dialpad member
uses: octokit/request-action@v2
with:
route: GET /orgs/dialpad/members/${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.DIALTONE_CI_TOKEN }}
deploy-dialtone:
needs: [cache-and-install, check-dialpad-member, get-branch-name, filter-actions]
if: ${{ needs.filter-actions.outputs.dialtone == 'true' }}
concurrency: ${{ github.workflow }}-${{ github.ref }}
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
env:
VUEPRESS_BASE_URL: ${{ github.ref == 'refs/heads/production' && '/' || format('/{0}/', needs.get-branch-name.outputs.current_branch) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 18
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Dialtone library and documentation site
run: npx nx run --verbose dialtone-documentation:build
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.DIALTONE_GCP_WIP }}
service_account: ${{ secrets.DIALTONE_GCP_SA }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
version: '>= 363.0.0'
- name: List bucket contents
run: gcloud storage ls gs://dialtone.dialpad.com
# - name: Clean up bucket
# if: ${{ github.ref == 'refs/heads/production' }}
# run: >
# gcloud storage ls gs://dialtone.dialpad.com |
# grep -v -E '
# /alpha/|
# /beta/|
# /legacy/|
# /next/|
# /deploy-previews/|
# /vue/|
# /vue3/|
# /staging/
# ' |
# gcloud storage rm --recursive --read-paths-from-stdin
#
# - name: Clean up bucket ${{ env.VUEPRESS_BASE_URL }} directory
# if: ${{ github.ref != 'refs/heads/production' }}
# run: gcloud storage rm --recursive ${{ format('gs://dialtone.dialpad.com{0}', env.VUEPRESS_BASE_URL) }}
#
# - name: Upload to GCP
# uses: google-github-actions/upload-cloud-storage@v1
# with:
# path: apps/dialtone-documentation/docs/.vuepress/dist
# destination: ${{ format('dialtone.dialpad.com{0}', env.VUEPRESS_BASE_URL) }}
# parent: false
# deploy-dialtone-vue:
# needs: cache-and-install
# if: ${{ needs.cache-and-install.outputs.dialtone-vue == 'true' }}
# concurrency: ${{ github.workflow }}-${{ github.ref }}
# runs-on: ubuntu-latest
# steps:
# - name: Build Dialtone Vue library and docsite
# run: npx nx run --verbose dialtone-vue3-documentation:build
#
# - name: Deploy Dialtone Vue to GitHub Pages
# uses: JamesIves/github-pages-deploy-action@v4.2.5
# with:
# branch: gh-pages
# folder: apps/dialtone-vue3-documentation/storybook-static
# target-folder: ${{ steps.branch-name.outputs.current_branch }}