-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (96 loc) · 3.72 KB
/
Copy pathcrawler-scope.yml
File metadata and controls
110 lines (96 loc) · 3.72 KB
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
name: CrawlerScope
on:
workflow_dispatch: {}
schedule:
- cron: "23 */6 * * *"
permissions:
contents: write
concurrency:
group: crawler-scope-${{ github.ref }}
cancel-in-progress: false
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Update crawler data
env:
CRAWLER_SCOPE_SNAPSHOT_RETENTION: "168"
CRAWLER_SCOPE_HISTORY_RETENTION: "720"
CRAWLER_SCOPE_USER_AGENT: "CrawlerScope/0.1 (+${{ github.server_url }}/${{ github.repository }}; GitHub Actions public-data collector)"
run: python3 scripts/update.py
- name: Commit updated data
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add data config
if git diff --cached --quiet; then
echo "No dataset changes to commit."
else
git commit -m "Update CrawlerScope data"
git push
fi
- name: Publish dataset release
env:
GH_TOKEN: ${{ github.token }}
run: |
stamp="$(python3 -c 'import json; print(json.load(open("data/current/crawlers.json"))["generatedAt"].replace(":", "").replace("-", "").replace("Z", "Z"))')"
tag="dataset-current" # rolling: одна страница релиза, апдейт на месте
snapshot="$(ls -1 data/snapshots/*.json | sort | tail -n 1)"
python3 scripts/release_notes.py > release-notes.md
if gh release view "$tag" >/dev/null 2>&1; then
gh release edit "$tag" \
--title "CrawlerScope dataset ${stamp}" \
--notes-file release-notes.md \
--latest
gh release upload "$tag" \
data/current/crawlers.json \
data/current/robots-ai.txt \
data/current/nginx-ai-map.conf \
data/history/summary.csv \
"$snapshot" \
--clobber
else
gh release create "$tag" \
data/current/crawlers.json \
data/current/robots-ai.txt \
data/current/nginx-ai-map.conf \
data/history/summary.csv \
"$snapshot" \
--title "CrawlerScope dataset ${stamp}" \
--notes-file release-notes.md \
--latest
fi
- name: Publish GitHub Pages branch
run: |
site_source="$RUNNER_TEMP/crawler-scope-site"
pages_dir="$RUNNER_TEMP/crawler-scope-pages"
rm -rf "$site_source" "$pages_dir"
mkdir -p "$site_source/data"
cp -R public/. "$site_source/"
cp -R data/. "$site_source/data/"
touch "$site_source/.nojekyll"
git fetch origin gh-pages --depth=1 || true
if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then
git worktree add "$pages_dir" origin/gh-pages
else
git worktree add --detach "$pages_dir"
git -C "$pages_dir" checkout --orphan gh-pages
git -C "$pages_dir" rm -rf . || true
fi
find "$pages_dir" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
cp -R "$site_source"/. "$pages_dir"/
git -C "$pages_dir" add -A
if git -C "$pages_dir" diff --cached --quiet; then
echo "No Pages changes to publish."
else
git -C "$pages_dir" commit -m "Publish CrawlerScope site"
git -C "$pages_dir" push origin HEAD:gh-pages
fi