-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
91 lines (86 loc) · 2.38 KB
/
.gitlab-ci.yml
File metadata and controls
91 lines (86 loc) · 2.38 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
variables:
GIT_DEPTH: 0
MKDOCS_IMAGE: ghcr.io/eda-labs/mkdocs-material:v9.7.5-3
default:
tags:
- esisogr87
htmltest:
stage: test
needs:
- job: build
artifacts: true
image:
name: cr.srlinux.dev/pub/debian:bookworm-slim
script:
- apt update && apt install -y --no-install-recommends curl file
ca-certificates findutils
- curl https://htmltest.wjdp.uk | bash
# Match run.sh test-docs: neutralize mike/version-picker href="../…" before link check
- find ./site -type f -name "*.html" -exec sed -i 's|href=\.\./[\.\/
]*>|href="#">|g' {} +
- ./bin/htmltest -c docs/htmltest.yml
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
build:
stage: build
image:
name: $MKDOCS_IMAGE
entrypoint: [ "" ]
cache:
key: mkdocs-cache
paths:
- .cache
when: always
unprotect: true
script:
- mkdocs build --site-dir site
artifacts:
paths:
- site
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
upload_preview:
stage: build
needs:
- job: build
artifacts: true
image:
name: $MKDOCS_IMAGE
entrypoint: [ "" ]
before_script:
- apk add --no-cache nodejs npm curl
- npm install -g wrangler
script:
- wrangler pages deploy site --project-name=eda-docs
--branch=$CI_COMMIT_REF_NAME | tee /tmp/wrangler.log
- DEPLOY_URL=$(grep -oE 'https?://[^[:space:]]+' /tmp/wrangler.log | sed -n
'1p')
- ALIAS_URL=$(grep -oE 'https?://[^[:space:]]+' /tmp/wrangler.log | sed -n
'2p')
- |
if [ -n "$DEPLOY_URL" ] && [ -n "$ALIAS_URL" ] && [ -n "$CI_MERGE_REQUEST_IID" ]; then
BODY=$(printf "Preview deploy: %s\n\nPreview alias: %s" "$DEPLOY_URL" "$ALIAS_URL")
curl --request POST \
--header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--data-urlencode "body=$BODY" \
--write-out " status=%{http_code}\n" \
--silent --show-error --fail \
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes"
else
echo "Preview URLs or MR IID missing; skipping comment."
fi
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
pages:
stage: deploy
image:
name: $MKDOCS_IMAGE
entrypoint: [ "" ]
script:
- mkdocs build --site-dir public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "main"