-
-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (175 loc) · 6.62 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
name: mono-repo [deploy]
run-name: Deploy to ${{ inputs.environment }} by @${{ github.actor }} on ${{ inputs.version || github.ref_name }}
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment of release'
type: environment
default: Development
required: true
deploy_web:
description: 'Deploy web to azure static'
type: boolean
default: false
required: true
upload_extension:
description: 'Upload extension to chrome webstore'
type: boolean
default: false
required: true
publish_extension:
description: 'Publish extension'
type: boolean
default: false
required: true
version:
description: 'Version (v4.0.0.0)'
type: string
jobs:
main:
name: Build & Bundle
environment:
name: ${{inputs.environment}}
url: ${{ steps.release.outputs.url || steps.artifact-upload-step.outputs.artifact-url}}
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
discussions: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com
scope: ${{github.repository_owner}}
cache: 'npm'
- uses: nrwl/nx-set-shas@v3
- run: |
echo "BASE: ${{ env.NX_BASE }}"
echo "HEAD: ${{ env.NX_HEAD }}"
- run: npm ci
- name: Build Projects and Library
run: npx nx run-many -t build -p acf-options-page acf-extension --prod --base-href ${{vars.PUBLIC_URL}} --verbose --skip-nx-cache
env:
NX_PUBLIC_NAME: ${{vars.NX_PUBLIC_NAME}}
NX_PUBLIC_VARIANT: ${{vars.NX_PUBLIC_VARIANT}}
NX_PUBLIC_CHROME_EXTENSION_ID: ${{vars.NX_PUBLIC_CHROME_EXTENSION_ID}}
NX_PUBLIC_EDGE_EXTENSION_ID: ${{vars.NX_PUBLIC_EDGE_EXTENSION_ID || 'DEV'}}
NX_PUBLIC_I18N: ${{vars.NX_PUBLIC_I18N}}
NX_PUBLIC_GOOGLE_ANALYTICS_ID: ${{vars.NX_PUBLIC_GOOGLE_ANALYTICS_ID}}
NX_PUBLIC_GOOGLE_ADS_SLOT: ${{vars.NX_PUBLIC_GOOGLE_ADS_SLOT}}
NX_PUBLIC_GOOGLE_ADS_CLIENT: ${{vars.NX_PUBLIC_GOOGLE_ADS_CLIENT}}
NX_PUBLIC_FIREBASE_API_KEY: ${{vars.NX_PUBLIC_FIREBASE_API_KEY}}
NX_PUBLIC_FIREBASE_DATABASE_URL: ${{vars.NX_PUBLIC_FIREBASE_DATABASE_URL}}
NX_PUBLIC_FIREBASE_PROJECT_ID: ${{vars.NX_PUBLIC_FIREBASE_PROJECT_ID}}
NX_PUBLIC_FIREBASE_BUCKET: ${{vars.NX_PUBLIC_FIREBASE_BUCKET}}
UNINSTALL_URL: ${{vars.UNINSTALL_URL}}
TRACKING_ID: ${{vars.TRACKING_ID}}
FUNCTION_URL: ${{vars.FUNCTION_URL}}
DISCORD_CLIENT_ID: ${{vars.DISCORD_CLIENT_ID}}
OAUTH_CLIENT_ID: ${{vars.OAUTH_CLIENT_ID}}
EDGE_OAUTH_CLIENT_ID: ${{vars.EDGE_OAUTH_CLIENT_ID}}
PUBLIC_URL: ${{vars.PUBLIC_URL}}
NX_PUBLIC_RELEASE_VERSION: ${{inputs.version || github.ref_name}}
API_SECRET: ${{vars.API_SECRET}}
MEASUREMENT_ID: ${{vars.MEASUREMENT_ID}}
- name: Print Environment Info
run: npx nx report
- name: Bundle Projects
run: |
mkdir bundle
cd dist/apps/acf-options-page
zip -r ../../../bundle/acf-options-page-${{vars.NX_PUBLIC_VARIANT}}.zip .
cd ..
cd acf-extension
zip -r ../../../bundle/acf-extension-${{vars.NX_PUBLIC_VARIANT}}.zip .
cd ..
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
id: release
with:
# token: $ {{ secrets.REPO_PAT }} # Use the PAT here
prerelease: ${{ vars.NX_PUBLIC_VARIANT == 'BETA' || vars.NX_PUBLIC_VARIANT == 'DEV'}}
generate_release_notes: true
discussion_category_name: 'Release'
fail_on_unmatched_files: true
files: bundle/*
- uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: nx-main-artifacts
path: bundle/*
extension:
if: ${{ inputs.upload_extension }}
name: Upload Extension
needs: [main]
environment:
name: ${{inputs.environment}}
url: 'https://chrome.google.com/webstore/devconsole/98df2dba-c751-4acf-a79a-af687cb603df'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: nx-main-artifacts
- name: Upload & release
uses: mnao305/chrome-extension-upload@v5.0.0
id: chrome-extension-upload
with:
file-path: acf-extension-${{vars.NX_PUBLIC_VARIANT}}.zip
extension-id: ${{ vars.NX_PUBLIC_CHROME_EXTENSION_ID }}
client-id: ${{ secrets.CLIENT_ID }}
client-secret: ${{ secrets.CLIENT_SECRET }}
refresh-token: ${{ secrets.REFRESH_TOKEN }}
publish: ${{inputs.publish_extension}}
glob: true
web:
if: ${{ inputs.deploy_web }}
name: Deploy Web
needs: [main]
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
environment:
name: ${{inputs.environment}}
url: ${{vars.PUBLIC_URL}}
steps:
- uses: actions/download-artifact@v4
with:
name: nx-main-artifacts
- name: unzip
run: unzip acf-options-page-${{vars.NX_PUBLIC_VARIANT}}.zip -d acf-options-page
- name: Build And Deploy
id: deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: 'upload'
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: 'acf-options-page' # App source code path
api_location: '' # Api source code path - optional
skip_app_build: true
skip_api_build: true
output_location: '' # Built app content directory - optional
###### End of Repository/Build Configurations ######
tag:
needs: [extension, web]
name: Create tag
runs-on: ubuntu-latest
environment: ${{inputs.environment}}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set ${{vars.NX_PUBLIC_VARIANT}} Tag
uses: rickstaa/action-create-tag@v1
with:
force_push_tag: true
tag: '${{vars.NX_PUBLIC_VARIANT}}'