-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (62 loc) · 2.43 KB
/
mozorg-cdn-geo-code-check.yaml
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# NB this workflow needs a cache of HTML documents, emitted by the main
# site-scanning workflow for the CDN origin only
name: Check CDN for geo stability
env:
SLACK_NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK_URL }}
on:
workflow_run:
workflows:
- Site scanning
types:
- completed
jobs:
check_geo_from_cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Download page cache
uses: actions/github-script@v7
with:
script: |
console.log("Getting all artifacts");
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
console.log("Filtering to the ones we care about here");
let matchedArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name.includes("html-cache");
});
for (let i=0; i < matchedArtifacts.length; i++){
artifact = matchedArtifacts[i];
console.log("Downloading artifact", artifact);
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
let fs = require('fs');
// ${process.env.GITHUB_WORKSPACE}/page_cache already exists because it's in the repo
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/page_cache/html-cache_${i}.zip`, Buffer.from(download.data));
console.log("Done");
};
- name: Unzip page cache
run: |
cd page_cache
unzip -o '*.zip'
cd ..
ls -la page_cache/
- name: Install requirements
run: pip install -r requirements.txt
- name: Scan the dumped cache for geo-code consistency
run: python bin/check_for_cdn_geo_consistency.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}