-
Notifications
You must be signed in to change notification settings - Fork 600
140 lines (122 loc) · 4.52 KB
/
cd-deploy-www-staging.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
name: Deploy Documentation (staging)
on:
push:
branches:
- master
paths:
- '.github/workflows/cd-deploy-www-staging.yml'
- 'packages/utilities/fast-animation/docs/api-report.md'
- 'packages/utilities/fast-color/docs/api-report.md'
- 'packages/utilities/fast-react-wrapper/docs/api-report.md'
- 'packages/web-components/**/docs/api-report.md'
- 'sites/fast-website/**'
- 'sites/website/**'
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master
paths:
- '.github/workflows/cd-deploy-www-staging.yml'
- 'packages/utilities/fast-animation/docs/api-report.md'
- 'packages/utilities/fast-color/docs/api-report.md'
- 'packages/utilities/fast-react-wrapper/docs/api-report.md'
- 'packages/web-components/**/docs/api-report.md'
- 'sites/fast-website/**'
- 'sites/website/**'
env:
AZURE_WEBAPP_ACTIVE_STAGE_NAME: www-west-app
AZURE_WEBAPP_PASSIVE_STAGE_NAME: www-east-app
AZURE_WEBAPP_BUILD_PATH: sites/website
AZURE_WEBAPP_DIST_PATH: sites/website/build
AZURE_WEBAPP_SLOT_NAME: stage
ARTIFACT_NAME: documentation-site
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: actions/checkout@master
- name: Install Lerna
run: yarn global add [email protected]
- name: Install package dependencies / prepare workspaces
run: yarn install --frozen-lockfile
- name: Build & Prepare Web Application
run: |
cd ${{ env.AZURE_WEBAPP_BUILD_PATH }}
yarn install
yarn build
cp ../site-utilities/statics/server/package.json ../site-utilities/statics/server/server.js build
cd build
npm i
ls -lta
- uses: actions/upload-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.AZURE_WEBAPP_DIST_PATH }}
deploy_to_staging:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy PR
uses: actions/download-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.AZURE_WEBAPP_DIST_PATH }}
- name: 'Deploy to Active Azure Region'
uses: azure/webapps-deploy@v2
with:
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_WWW_ACTIVE }}
app-name: ${{ env.AZURE_WEBAPP_ACTIVE_STAGE_NAME }}
package: ${{ env.AZURE_WEBAPP_DIST_PATH }}
slot-name: ${{ env.AZURE_WEBAPP_SLOT_NAME }}
- name: 'Deploy to Passive Azure Region'
uses: azure/webapps-deploy@v2
with:
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_WWW_PASSIVE }}
app-name: ${{ env.AZURE_WEBAPP_PASSIVE_STAGE_NAME }}
package: ${{ env.AZURE_WEBAPP_DIST_PATH }}
slot-name: ${{ env.AZURE_WEBAPP_SLOT_NAME }}
deploy_pr:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy PR
uses: actions/download-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.AZURE_WEBAPP_DIST_PATH }}
- name: Deploy Documentation
id: deploypr
uses: Azure/[email protected]
continue-on-error: ${{ (github.event_name == 'pull_request' && github.event.action != 'closed') }}
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APP_WWW_PR_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
app_location: ${{ env.AZURE_WEBAPP_DIST_PATH }}
output_location: ''
skip_app_build: true
destroy_pr:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Destroy PR
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APP_WWW_PR_TOKEN }}
action: 'close'
notify:
runs-on: ubuntu-latest
needs: deploy_to_staging
steps:
- name: Notify on Discord
uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.DISCORD_NOTIFICATION_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_NOTIFICATION_WEBHOOK_TOKEN }}
color: '#DE2D6D'
username: 'FAST DevOps Documentation Bot'
message: 'Deployment has completed to Staging on https://github.com/microsoft/fast/actions/workflows/cd-deploy-www-staging.yml'