-
Notifications
You must be signed in to change notification settings - Fork 26
212 lines (178 loc) · 5.55 KB
/
deploy-website.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
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Deploy website
on: workflow_dispatch
concurrency:
group: website-deployer
cancel-in-progress: true
permissions:
contents: write
jobs:
versioning:
name: Define version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.marker.outputs.version }}
steps:
- name: Define marker
id: marker
run: echo "version=$(date +'%Y.%m.%d')-${{ github.run_number }}" >> $GITHUB_OUTPUT
- name: Summary output
run: |
{
echo "| Info | Value |"
echo "| :--- | :---- |"
echo "| Version | ${{ steps.marker.outputs.version }} |"
} >> $GITHUB_STEP_SUMMARY
build-backend:
name: Build backend
runs-on: ubuntu-latest
needs:
- versioning
env:
url: https://charts.stockindicators.dev
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.x"
dotnet-quality: "ga"
- name: Replace cache markers
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "YYYY.MM.DD"
replace: "${{ needs.versioning.outputs.version }}"
regex: false
- name: Build .NET solution
run: >
dotnet build server/ChartBackend.sln
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Package Web API
if: github.ref == 'refs/heads/main'
working-directory: server
run: >
dotnet publish WebApi/WebApi.csproj
--configuration Release
--property:PublishDir="../artifacts/api"
- name: Package Functions
if: github.ref == 'refs/heads/main'
working-directory: server
run: >
dotnet publish Functions/Functions.csproj
--configuration Release
--property:PublishDir="../artifacts/fns"
- name: Save Web API
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: api
path: "server/artifacts/api"
include-hidden-files: true
- name: Save Functions
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: fns
path: "server/artifacts/fns"
include-hidden-files: true
build-website:
name: Build website
runs-on: ubuntu-latest
needs:
- versioning
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: "npm"
cache-dependency-path: client/package-lock.json
- name: Install dependencies
working-directory: client
run: npm install
- name: Replace cache markers
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "YYYY.MM.DD"
replace: "${{ needs.versioning.outputs.version }}"
regex: false
- name: Update configs
shell: pwsh
working-directory: client/src
run: |
(Get-Content index.html).Replace("__GaTag__", "G-17DX6ZW6HP") | Set-Content index.html
Write-Host "... Done!"
- name: Build site
working-directory: client
run: npm run build.prod
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: web
path: client/dist/app/browser
include-hidden-files: true
deploy:
name: Deploy
runs-on: ubuntu-latest
needs:
- versioning
- build-backend
- build-website
environment:
name: charts.stockindicators.dev
url: "https://charts.stockindicators.dev"
steps:
- name: Download Functions package
if: github.ref == 'refs/heads/main'
uses: actions/download-artifact@v4
with:
name: fns
path: artifacts/fns
- name: Download API package
if: github.ref == 'refs/heads/main'
uses: actions/download-artifact@v4
with:
name: api
path: artifacts/api
- name: Download Web package
uses: actions/download-artifact@v4
with:
name: web
path: artifacts/web
- name: Deploy Functions
if: github.ref == 'refs/heads/main'
uses: Azure/functions-action@v1
with:
app-name: stock-charts-functions
package: artifacts/fns
publish-profile: ${{ secrets.PUBLISH_PROFILE_FNS }}
- name: Deploy API
if: github.ref == 'refs/heads/main'
uses: azure/webapps-deploy@v3
with:
app-name: stock-charts-api
package: artifacts/api
publish-profile: ${{ secrets.PUBLISH_PROFILE_API }}
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_KEY }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "latest"
command: >
pages deploy artifacts/web
--project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }}
- name: Tag and draft release note
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/main'
with:
body: |
We’ve updated [charts.stockindicators.dev](https://charts.stockindicators.dev)
generateReleaseNotes: true
draft: true
tag: ${{ needs.versioning.outputs.version }}
commit: ${{ github.ref_name }}