-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
146 lines (132 loc) · 4.75 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
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
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'.
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
runs:
using: composite
steps:
- name: ⬇️ Set up code
uses: actions/checkout@v3
- name: ⎔ Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- name: 📥 Download dependencies
shell: bash
run: npm ci
- name: 👥 Copy ArcGIS assets
shell: bash
run: npm run copy:arcgis --if-present
- name: 🍳 Run prebuild command
if: ${{ inputs.prebuild-command != '' }}
shell: bash
run: ${{ inputs.prebuild-command }}
- name: 🏗 Run build command
shell: bash
run: ${{ inputs.build-command }}
- name: 🪣 Cache firebase
uses: actions/cache@v3
with:
path: ./.firebase
key: ${{ runner.OS }}-firebase-${{ hashFiles('**/*.cache') }}
restore-keys: |
${{ runner.OS }}-firebase-
${{ runner.OS }}-
- name: 🗝️ Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v0
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: ❓ Determining if preview should be created
id: should-create-preview
if: inputs.preview == 'yes' && github.head_ref != 'dev'
shell: bash
run: echo "::set-output name=deploy::yes"
- name: 🚀 Firebase deploy preview
id: deploy
if: steps.should-create-preview.outputs.deploy == 'yes'
shell: bash
run: |
RESULTS=$(npx firebase-tools hosting:channel:deploy $GITHUB_HEAD_REF \
--expires 3d \
--project ${{ inputs.project-id }} \
--json)
echo "::set-output name=url::$(echo $RESULTS | jq --raw-output '.result | .[] | .url')"
echo "::set-output name=expires::$(echo $RESULTS | jq '.result | .[] | .expireTime')"
- name: 🚀 Firebase deploy
shell: bash
if: inputs.preview != 'yes'
run: >
npx firebase-tools deploy
--only hosting
--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@v2
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@v2
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 }}