-
Notifications
You must be signed in to change notification settings - Fork 202
141 lines (116 loc) · 4.62 KB
/
webapp-edge.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
name: WebApp (JS) - Edge
on:
push:
paths:
- '.github/workflows/webapp-edge.yml'
- 'source/WebApp/**'
- 'source/#external/mirrorsharp/WebAssets/**'
- 'source/#external/mirrorsharp-codemirror-6-preview/WebAssets/**'
pull_request:
workflow_dispatch:
jobs:
build:
name: Build
# https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
working-directory: source/WebApp
steps:
- run: git config --global core.autocrlf false
working-directory: /home
- uses: actions/checkout@v3
with:
submodules: 'true'
lfs: 'true'
- run: git lfs checkout
- uses: actions/setup-node@v3
with:
node-version: '16.17.1'
- run: 'git show ${{ github.sha }} --format="version_number=%cd" --date=format:%Y-%m-%d-%H%M --no-patch >> $GITHUB_OUTPUT'
id: version
- name: Run npm ci (mirrorsharp)
run: npm ci
working-directory: source/#external/mirrorsharp/WebAssets
- name: Run npm run build (mirrorsharp)
run: npm run build
working-directory: source/#external/mirrorsharp/WebAssets
- name: Run npm ci (mirrorsharp-codemirror-6-preview)
run: npm ci
working-directory: source/#external/mirrorsharp-codemirror-6-preview/WebAssets
- name: Run npm run build (mirrorsharp-codemirror-6-preview)
run: npm run build
working-directory: source/#external/mirrorsharp-codemirror-6-preview/WebAssets
- run: npm ci
- run: npm run build-ci
env:
NODE_ENV: production
SHARPLAB_WEBAPP_BUILD_VERSION: ${{ steps.version.outputs.version_number }}
- run: npm run test
- run: npm run build-storybook
env:
NODE_ENV: test
- run: npm run test-storybook
- name: "[Failure] Run actions/upload-artifact@v3 (diff output)"
uses: actions/upload-artifact@v3
if: failure()
with:
name: __diff_output__
path: source/WebApp/app/**/__snapshots__/**/__diff_output__/**/*.*
if-no-files-found: ignore
- name: "[Failure] Run npm run test-storybook-update"
run: npm run test-storybook-update
if: failure()
- name: "[Failure] Run actions/upload-artifact@v3 (updated snapshots)"
uses: actions/upload-artifact@v3
if: failure()
with:
name: '__snapshots__ (updated)'
path: source/WebApp/app/**/__snapshots__/**/*.*
if-no-files-found: ignore
- uses: actions/upload-artifact@v3
with:
name: WebApp
path: source/WebApp/WebApp.zip
if-no-files-found: error
- uses: ncipollo/release-action@b072aaafe138c5ecf1c39f714a76bce6f0d0bc9c
if: github.ref == 'refs/heads/main'
id: create_release
with:
artifacts: ./source/WebApp/WebApp.zip
artifactContentType: application/zip
tag: webapp-release-${{ steps.version.outputs.version_number }}
deploy-to-edge:
name: Deploy (Edge)
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/execution-flow-output-squashed'
environment: edge-webapp
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: WebApp
- run: Expand-Archive WebApp.zip ./WebApp
shell: pwsh
- run: Rename-Item ./WebApp/latest latest-edge
shell: pwsh
- uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: "Run azure/CLI@e43928ebbc386700c6bb2f42a97a8de31576cfd2: az storage blob upload-batch"
uses: azure/CLI@e43928ebbc386700c6bb2f42a97a8de31576cfd2
with:
azcliversion: 2.30.0
inlineScript: |
az storage blob upload-batch --account-name slpublic -d assets -s WebApp
- run: Invoke-RestMethod -Method POST -Uri 'https://edge.sharplab.io/assets/reload' -Authentication Bearer -Token $(ConvertTo-SecureString $env:SHARPLAB_ASSETS_RELOAD_TOKEN -AsPlainText)
shell: pwsh
env:
SHARPLAB_ASSETS_RELOAD_TOKEN: ${{ secrets.SHARPLAB_ASSETS_RELOAD_TOKEN }}