-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
executable file
·163 lines (151 loc) · 4.84 KB
/
.gitlab-ci.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
---
stages:
- test
- build
- url-test
- publish
- upload-prep
- trigger-upload
include:
- project: saltstack/pop/cicd/ci-templates
file: /docswork/publish-docs-gitlab.yml
- project: saltstack/pop/cicd/ci-templates
file: /docswork/salt-publish-docs-release.yml
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID == null
variables:
CICD_UPSTREAM_PATH: "saltstack/open/docs/salt-install-guide"
GIT_STRATEGY: clone
GIT_DEPTH: 0
pre-commit:
stage: test
image: python:3.11-buster
variables:
PRE_COMMIT_HOME: "${CI_PROJECT_DIR}/pre-commit-cache"
cache:
key: pre-commit-cache
paths:
- pre-commit-cache/
script:
- pip install -U pip setuptools wheel
- pip install -r requirements-dev.txt
- pre-commit install
- pre-commit run -a -v --color always
build-site-3007:
stage: build
image: python:3.11
script:
- git checkout v3007
- pip install -U pip setuptools wheel nox
- nox -e 'docs-html(download_versions=True, clean=True)'
- mkdir -p html/en/
- mv docs/_build/html html/en/3007
# The following section should only exist on the build meant to be latest build
# Make sure to modify the first line to target the latest version
- |
cp -r html/en/3007 html/en/latest
echo '<!DOCTYPE html>' > docs/redirector.html
echo "<html>
<head>
<meta http-equiv=\"refresh\" content=\"0; url='./latest/index.html'\" />
</head>
</html>" >> docs/redirector.html
cp docs/redirector.html html/index.html
cp docs/redirector.html html/en/index.html
sed -i 's:./latest/index.html:./en/latest/index.html:' html/index.html
artifacts:
paths:
- html
expire_in: 1 days
rules:
- if: '$CI_PROJECT_PATH == $CICD_UPSTREAM_PATH'
build-site-3006:
stage: build
image: python:3.11
script:
- git checkout v3006.0
- pip install -U pip setuptools wheel nox
- nox -e 'docs-html(download_versions=True, clean=True)'
- mkdir -p html/en/
- mv docs/_build/html html/en/3006
artifacts:
paths:
- html
expire_in: 1 days
rules:
- if: '$CI_PROJECT_PATH == $CICD_UPSTREAM_PATH'
build-site-main:
stage: build
image: python:3.11
script:
- git checkout main
- pip install -U pip setuptools wheel nox
- nox -e 'docs-html(download_versions=True, clean=True)'
- mkdir -p html/en/
- mv docs/_build/html html/en/main
artifacts:
paths:
- html
expire_in: 1 days
rules:
- if: '$CI_PROJECT_PATH == $CICD_UPSTREAM_PATH'
build-site-fork:
stage: build
image: python:3.11
script:
- pip install -U pip setuptools wheel nox
- nox -e 'docs-html(download_versions=True, clean=True)'
- mkdir -p html/en/
- mv docs/_build/html html/en/fork
# This section ensures that GitLab Pages builds for forks
# properly build and can be visited
# ex. https://your-GitLab-username.gitlab.io/salt-install-guide
# Above redirects to: https://your-GitLab-username.gitlab.io/salt-install-guide/en/fork/index.html
- |
echo '<!DOCTYPE html>' > docs/redirector.html
echo "<html>
<head>
<meta http-equiv=\"refresh\" content=\"0; url='./fork/index.html'\" />
</head>
</html>" >> docs/redirector.html
cp docs/redirector.html html/index.html
cp docs/redirector.html html/en/index.html
sed -i 's:./fork/index.html:./en/fork/index.html:' html/index.html
artifacts:
paths:
- html
expire_in: 1 days
rules:
- if: '$CI_COMMIT_BRANCH != "main" && $CI_COMMIT_BRANCH != "v3007" && $CI_COMMIT_BRANCH != "v3006.0" && $CI_COMMIT_BRANCH != "v3005" && $CI_PROJECT_PATH != $CICD_UPSTREAM_PATH'
url-tester-brok:
stage: url-test
image: debian:bullseye-slim
script:
- apt-get update && apt-get install wget libtinfo5 -y
- wget https://github.com/smallhadroncollider/brok/releases/download/1.1.0/brok-1.1.0_x86-64-linux.deb
- dpkg -i brok-1.1.0_x86-64-linux.deb
- rm docs/_templates/sitevars.rst
- brok --ignore $(cat .brokignore) $(find . -type f -name "*.rst") $(find . -type f -name "*.md") $(find . -type f -name "*.toml") $(find . -type f -name "*.sls") $(find . -type f -name "*.py") $(find . -type f -name "*.y*ml") $(find . -type f -name "*.html") > /dev/null
pages:
stage: publish
upload-prep:
stage: upload-prep
image: python:3.11
script:
- cp -r public public-prod
- rm -rf public-prod/en/main
artifacts:
paths:
- public-prod
expire_in: 1 days
rules:
- if: '$CI_PROJECT_PATH == $CICD_UPSTREAM_PATH && $CI_COMMIT_REF_PROTECTED == "true"'
publish-docs:
stage: trigger-upload
variables:
CICD_S3_SOURCE_PATH: "public-prod/"
CICD_S3_DEST_PATH: "docs.saltproject.io/salt/install-guide/"
CICD_SOURCE_GITLAB_JOB_NAME: upload-prep
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_PROJECT_PATH == $CICD_UPSTREAM_PATH'