-
Notifications
You must be signed in to change notification settings - Fork 192
185 lines (164 loc) · 6.01 KB
/
docs.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
name: Docs checker
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
aka-validation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo:
- TeamsFx
- TeamsFx.wiki
- TeamsFx-Samples
steps:
- name: Checkout TeamsFx.wiki
uses: actions/checkout@v3
with:
repository: OfficeDev/${{ matrix.repo }}
- name: List akas
id: list-akas
run: |
links=`git grep -hEo "https://aka[a-zA-Z0-9./?=_%:-]*[a-zA-Z0-9]" | sort -nr | uniq`
white_list="https://aka.ms/teamsfx-plugin-api;https://aka.ms/dotnet;https://aka.ms/teamsfx-migrate-v1"
while IFS= read -r link;
do
if [[ $white_list == *"$link"* ]]; then
echo $link "=>" "white list" >> akas.data
continue
fi
redirect=`curl -LIs -o /dev/null -w %{url_effective} $link`
echo $link "=>" $redirect >> akas.data
done <<< $links
- name: Upload akas to artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.repo }}
path: akas.data
output-link-result:
runs-on: ubuntu-latest
needs: aka-validation
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: List akas
id: list-akas
working-directory: artifacts
run: |
files=(*)
lists=""
touch result.txt
for file in "${files[@]}";
do
echo $file
while IFS= read -r line
do
aka=`echo $line | awk -F '=>' '{print $1}'`
redirect=`echo $line | awk -F '=>' '{print $2}'`
label=""
if [[ $redirect == *"bing.com"* ]];
then
label="INVALID"
elif [[ $redirect == *"white list"* ]];
then
label="SKIPPED"
else
httpcode=`curl -s -o /dev/null -w %{http_code} $redirect`
if [[ $httpcode == 404 ]];
then
label="INVALID"
else
label="VALID"
fi
fi
row="$file $aka $label"
echo $row >> result.txt
done < $file/akas.data
done
- name: upload result to artifact
uses: actions/upload-artifact@v3
with:
name: result
path: artifacts/result.txt
report:
runs-on: ubuntu-latest
needs: aka-validation
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: List akas
id: list-akas
working-directory: artifacts
run: |
files=(*)
lists=""
emails="[email protected]"
valid=0
invalid=0
for file in "${files[@]}";
do
echo $file
while IFS= read -r line
do
aka=`echo $line | awk -F '=>' '{print $1}'`
redirect=`echo $line | awk -F '=>' '{print $2}'`
label=""
invalid_url=false
if [[ $redirect == *"bing.com"* ]];
then
invalid_url=true
invalid=$((invalid+1))
label="<span style=\\\"background-color: #dc322f;color:white;font-weight:bold;\\\">INVALID</span>"
elif [[ $redirect == *"white list"* ]];
then
valid=$((valid+1))
label="<span style=\\\"background-color:#b58900;color:white;font-weight:bold;\\\">SKIPPED</span>"
else
httpcode=`curl -s -o /dev/null -w %{http_code} $redirect`
if [[ $httpcode == 404 ]];
then
invalid_url=true
invalid=$((invalid+1))
label="<span style=\\\"background-color: #dc322f;color:white;font-weight:bold;\\\">INVALID</span>"
else
valid=$((valid+1))
label="<span style=\\\"background-color:#2aa198;color:white;font-weight:bold;\\\">VALID</span>"
fi
fi
row="<tr> <td style=\\\"text-align: left;\\\">$file</td> <td style=\\\"text-align: left;\\\">$aka</td> <td style=\\\"text-align: center;\\\">$label</td> </tr>"
echo $row
if [[ $invalid_url == true ]];
then
lists="$row $lists"
else
lists="$lists $row"
fi
done < $file/akas.data
done
body="Dashboard App: <a href=\\\"https:\/\/teams.microsoft.com\/l\/entity\/c439ae8d-3ab3-4efd-9223-87366d8c170c\/_djb2_msteams_prefix_1252604900?context=%7B%22channelId%22%3A%2219%3A79488ced607f4fbf8d8433e931cad176%40thread.tacv2%22%7D&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47\\\">Click Here to Open Dashboard App</a> <table class=\\\"w3-table w3-striped w3-bordered\\\"> <tr> <th>REPO</th> <th>AKA</th> <th>STATUS</th> </tr> $lists </table> <br />"
total=$((valid+invalid))
subject="TeamsFx AKA Link Report ($valid/$total Passed)"
if [ $invalid -gt 0 ]; then
subject="[FAILED] $subject"
emails="$emails;[email protected]"
else
subject="[PASSED] $subject"
fi
echo "body=$body" >> $GITHUB_OUTPUT
echo "to=$emails" >> $GITHUB_OUTPUT
echo "subject=$subject" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v3
- name: Send E-mail to the whole team
uses: ./.github/actions/send-email-report
env:
TO: ${{ steps.list-akas.outputs.to }}
BODY: '"${{ steps.list-akas.outputs.body }}"'
SUBJECT: ${{ steps.list-akas.outputs.subject }}
MAIL_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
MAIL_CLIENT_SECRET: ${{ secrets.TEST_CLEAN_CLIENT_SECRET }}
MAIL_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}