-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitbucket-pipelines.yml
127 lines (123 loc) · 6.27 KB
/
bitbucket-pipelines.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
image: node:18-alpine
definitions:
steps:
- step: &default
artifacts:
- 'docs/**'
clone:
depth: full
- step: &build-docs
<<: *default
caches:
- pip
- node
artifacts:
- 'site/**'
image: heptacom/mkdocs-pipeline:2.0.0
name: Build documentation assets
script:
- npm install --global cross-env
- npm ci --include=dev
- pip install -r requirements.txt
- PATH=.bin:$PATH make build
- step: &commit-built-docs
<<: *default
name: Commit docs
artifacts:
- docs/meta-descriptions.csv
script:
- apk add --update --no-cache git openssh-client
- mv .gh-pages-gitignore .gitignore
- git rm -r docs/
- rm -rf docs/
- mv site/ docs/
- git stash
- git checkout -b gh-pages
- git stash apply
- git add --all
- test $(git diff --name-only --cached | wc -l) -eq 0 || git commit -m "Build gh-pages"
- git push --force origin gh-pages
- step: &publish-docs
<<: *default
name: Publish to github
script:
- apk add --update --no-cache git openssh-client rsync
- rsync -avz --delete -e ssh ./docs/ "${RSYNC_TARGET}"
- git remote add github [email protected]:HEPTACOM/heptaconnect-docs.git
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git remote update
- git fetch --all
- git push --force github gh-pages
- git checkout --track origin/master
- git push --force github master
- step: &clear-cache
clone:
enabled: false
image: curlimages/curl:latest
name: Clear hosting cache
script:
- |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" -H "Content-Type: application/json" --data '{"purge_everything":true}'
- step: &validate-feed
clone:
enabled: false
image: curlimages/curl:latest
name: Validate RSS2 and Atom1 Feed
artifacts:
- 'feed-test/**'
script:
- test -d feed-test || mkdir feed-test
- |
curl -X POST https://validator.w3.org/feed/check.cgi -H 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'manual=0' --data-urlencode "rawdata=$(cat ./site/news/rss2.xml)" --output feed-test/rss2-pre.html
curl -X POST https://validator.w3.org/feed/check.cgi -H 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'manual=0' --data-urlencode "rawdata=$(cat ./site/news/atom1.xml)" --output feed-test/atom1-pre.html
- cat feed-test/rss2-pre.html | sed 's#<head>#<head><base href="https://validator.w3.org/feed/">#' > feed-test/rss2.html
- cat feed-test/atom1-pre.html | sed 's#<head>#<head><base href="https://validator.w3.org/feed/">#' > feed-test/atom1.html
- rm feed-test/rss2-pre.html
- rm feed-test/atom1-pre.html
- |
if ! grep 'feed-test/rss2.html' -e 'This is a valid RSS feed'; then
echo 'The RSS2 feed is not valid. Inspect the attached feed-test/rss2.html test result'
exit 1
fi
- |
if grep 'feed-test/rss2.html' -e 'Recommendations'; then
echo 'The RSS2 feed is valid but has recommendations. Inspect the attached feed-test/rss2.html test result'
if grep 'feed-test/rss2.html' -e 'href="docs/' | grep -v 'docs/warning/SelfDoesntMatchLocation.html' | grep -v 'docs/warning/ImplausibleDate.html' | grep -v 'href="docs/"'; then
exit 2
else
echo 'Only "self link" or "date in future" recommendation has been found. We are cool with this.'
fi
fi
- |
if ! grep 'feed-test/atom1.html' -e 'This is a valid Atom 1.0 feed'; then
echo 'The Atom1 feed is not valid. Inspect the attached feed-test/atom1.html test result'
exit 3
fi
- |
if grep 'feed-test/atom1.html' -e 'Recommendations'; then
echo 'The Atom1 feed is valid but has recommendations. Inspect the attached feed-test/atom1.html test result'
if grep 'feed-test/atom1.html' -e 'href="docs/' | grep -v 'docs/warning/SelfDoesntMatchLocation.html' | grep -v 'docs/warning/ImplausibleDate.html' | grep -v 'href="docs/"'; then
exit 4
else
echo 'Only "self link" or "date in future" recommendation has been found. We are cool with this.'
fi
fi
pipelines:
branches:
master:
- step: *build-docs
- step: *commit-built-docs
gh-pages:
- step:
name: Skip for manual step
script:
- echo "hello"
- step:
<<: *publish-docs
deployment: production
trigger: manual
- step: *clear-cache
pull-requests:
'**':
- step: *build-docs
- step: *validate-feed