-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
186 lines (169 loc) · 6.38 KB
/
action.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
name: 🚀 Deploy
description: Deploys a website to Firebase Hosting
inputs:
identity-provider:
description: Identity Provider
required: true
service-account-email:
description: Service Account Email
required: true
project-id:
description: Project ID or alias. This also sets the firebase environment (https://firebase.google.com/docs/functions/config-env).
required: true
preview:
description: Determines if firebase deploys to a preview channel
required: false
default: 'no'
prebuild-command:
description: The command run before the app is built
required: false
build-command:
description: The command used to build the app
required: true
repo-token:
description: GitHub token (e.g. secrets.GITHUB_TOKEN). This is only required if preview == 'yes' or if you are passing a value to service-now-system-id.
required: false
service-now-instance:
description: the sub address to https://{service-now-instance}.service-now.com
required: false
service-now-table:
description: the parent table name to write to
required: false
service-now-system-id:
description: the child record id to write to
required: false
service-now-username:
description: the service account name
required: false
service-now-password:
description: the service account password
required: false
working-directory:
description: The directory to run the build command in
required: false
default: '.'
runs:
using: composite
steps:
- name: ⬇️ Set up code
uses: actions/checkout@v4
with:
show-progress: false
- name: ❓ Determine Package Manager
shell: bash
working-directory: ${{ inputs.working-directory }}
id: package-manager
run: |
if [ -f pnpm-lock.yaml ]; then
echo "Using PNPM"
echo "name=pnpm" >> $GITHUB_OUTPUT
else
echo "Using NPM"
echo "name=npm" >> $GITHUB_OUTPUT
fi
- name: 📦 Setup PNPM
if: steps.package-manager.outputs.name == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: latest
- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: ${{ steps.package-manager.outputs.name }}
cache-dependency-path: ${{ inputs.working-directory }}
- name: 📥 Download dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: ${{ steps.package-manager.outputs.name }} install
- name: 👥 Copy ArcGIS assets
shell: bash
working-directory: ${{ inputs.working-directory }}
run: ${{ steps.package-manager.outputs.name }} run --if-present copy:arcgis
- name: 🗝️ Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
access_token_scopes: 'email, openid, https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/firebase'
workload_identity_provider: ${{ inputs.identity-provider }}
service_account: ${{ inputs.service-account-email }}
create_credentials_file: true
- name: 🍳 Run prebuild command
if: inputs.prebuild-command != ''
shell: bash
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.prebuild-command }}
- name: 🏗 Run build command
shell: bash
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.build-command }}
- name: 🦤 Cache bower
uses: actions/cache@v4
with:
path: ~/.cache/bower
key: ${{ runner.OS }}-bower-${{ hashFiles('bower.json') }}
restore-keys: |
${{ runner.OS }}-bower-
${{ runner.OS }}
- name: ❓ Determining if preview should be created
id: should-create-preview
if: inputs.preview == 'yes'
shell: bash
run: echo "deploy=yes" >> $GITHUB_OUTPUT
- name: 🪣 Cache firebase
uses: actions/cache@v4
with:
path: ${{ inputs.working-directory }}/.firebase
key: ${{ runner.OS }}-firebase-${{ hashFiles('**/*.cache') }}
restore-keys: |
${{ runner.OS }}-firebase-
${{ runner.OS }}-
- name: 🚀 Firebase deploy preview
id: deploy
if: steps.should-create-preview.outputs.deploy == 'yes'
shell: 'script --return --quiet --command "bash {0}"'
working-directory: ${{ inputs.working-directory }}
run: |
RESULTS=$(npx firebase-tools hosting:channel:deploy $GITHUB_HEAD_REF \
--expires 14d \
--project ${{ inputs.project-id }} \
--json | tee /dev/tty)
echo "url=$(echo $RESULTS | jq --raw-output '.result | .[] | .url' | tr '\n' ' | ')" >> $GITHUB_OUTPUT
echo "expires=$(echo $RESULTS | jq '.result | .[] | .expireTime' | tr '\n' ' | ')" >> $GITHUB_OUTPUT
- name: 🚀 Firebase deploy
shell: bash
if: inputs.preview != 'yes'
working-directory: ${{ inputs.working-directory }}
run: >
npx firebase-tools deploy
--project ${{ inputs.project-id }}
- name: 🔔 Publish deployment worknote
uses: agrc/service-now-worknote-action@v1
if: inputs.service-now-system-id != '' && inputs.preview != 'yes'
with:
repo-token: ${{ inputs.repo-token }}
username: ${{ inputs.service-now-username }}
password: ${{ inputs.service-now-password }}
instance-name: ${{ inputs.service-now-instance }}
table-name: ${{ inputs.service-now-table }}
system-id: ${{ inputs.service-now-system-id }}
- name: 🔍 Find preview comment
id: find-comment
uses: peter-evans/find-comment@v3
if: steps.should-create-preview.outputs.deploy == 'yes'
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: Visit the preview URL for this PR
- name: 💬 Post preview comment
uses: peter-evans/create-or-update-comment@v4
if: steps.should-create-preview.outputs.deploy == 'yes'
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body: |
Visit the preview URL for this PR (updated for commit ${{ github.sha }}):
Firebase Preview: ${{ steps.deploy.outputs.url }}
<sub>(expires ${{ steps.deploy.outputs.expires }})</sub>
edit-mode: replace
token: ${{ inputs.repo-token }}