Skip to content

Commit 5e0fef4

Browse files
committed
Squashed '.circleci/' content from commit 6c723987
git-subtree-dir: .circleci git-subtree-split: 6c72398757cd5dcd5f7a296bbaadcfe97061e8de
0 parents  commit 5e0fef4

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Docs CI config
2+
3+
This is the CircleCI config for building documentation from docs repos.
4+
5+
In order to use it, add this repo as a Git subtree to a docs repo under the directory ".circleci". The docs repo can then be built using CircleCI.
6+
7+
8+
## Making changes to the config
9+
10+
When changes are made to this config repo, use the Git subtree command to pull the latest changes to the subtree in the docs repo.
11+

config.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
version: 2.1
2+
3+
references:
4+
workspace_root: &workspace_root /tmp/workspace
5+
attach_workspace: &attach_workspace
6+
attach_workspace:
7+
at: *workspace_root
8+
9+
executors:
10+
doc_builder:
11+
docker:
12+
- image: mbed/doc_builder:latest
13+
auth:
14+
username: $DOCKER_USER
15+
password: $DOCKER_PASS
16+
17+
commands:
18+
setup_aws_credentials:
19+
description: "Setup AWS credentials"
20+
steps:
21+
- run:
22+
name: Write credentials to ~/.aws/credentials
23+
command: |
24+
mkdir ~/.aws
25+
echo -e "[default]\naws_access_key_id=$AWS_PROD_ACCESS_KEY_ID\naws_secret_access_key=$AWS_PROD_SECRET_KEY\n" > ~/.aws/credentials
26+
write_env_variables:
27+
description: "Write ENV variables"
28+
steps:
29+
- run:
30+
command: |
31+
echo "export CIRCLE_BRANCH_NO_SLASH=$(echo $CIRCLE_BRANCH|sed 's/\//-/')" >> /tmp/env
32+
echo "export BUILD_DIRECTORY=$CIRCLE_SHA1-$CIRCLE_WORKFLOW_ID" >> /tmp/env
33+
jobs:
34+
build:
35+
executor: doc_builder
36+
steps:
37+
- checkout
38+
- setup_aws_credentials
39+
- write_env_variables
40+
- run:
41+
name: Validate redirects
42+
command: |
43+
if [ -f "$HOME/project/redirects.json" ]; then
44+
python -mjson.tool "$HOME/project/redirects.json" > /dev/null
45+
fi
46+
- run:
47+
name: Validate and build documentation
48+
command: |
49+
source /tmp/env
50+
docbuilder build $CIRCLE_BRANCH_NO_SLASH /tmp/workspace/artifacts --path ~/project/docs.json --github_token "$GITHUB_TOKEN"
51+
- persist_to_workspace:
52+
root: *workspace_root
53+
paths:
54+
- artifacts
55+
56+
publish_to_s3:
57+
executor: doc_builder
58+
steps:
59+
- setup_aws_credentials
60+
- write_env_variables
61+
- *attach_workspace
62+
- run:
63+
name: Upload documentation to s3
64+
command: |
65+
source /tmp/env
66+
docbuilder publish /tmp/workspace/artifacts/$CIRCLE_BRANCH_NO_SLASH iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/$BUILD_DIRECTORY
67+
push_redirects_to_s3:
68+
executor: doc_builder
69+
steps:
70+
- checkout
71+
- setup_aws_credentials
72+
- write_env_variables
73+
- *attach_workspace
74+
- run:
75+
name: Upload redirects.json to s3
76+
command: |
77+
source /tmp/env
78+
docbuilder upload_file ~/project/redirects.json iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/redirects.json
79+
zip_documentation:
80+
machine: true
81+
steps:
82+
- *attach_workspace
83+
- run:
84+
name: Zip built documentation
85+
command: |
86+
cd /tmp/workspace/artifacts
87+
zip -r /tmp/workspace/docs.zip .
88+
- store_artifacts:
89+
path: /tmp/workspace/docs.zip
90+
91+
list_pages:
92+
machine: true
93+
steps:
94+
- write_env_variables
95+
- *attach_workspace
96+
- run:
97+
name: List all built docs pages
98+
command: |
99+
source /tmp/env
100+
cd /tmp/workspace/artifacts/$CIRCLE_BRANCH_NO_SLASH
101+
find -maxdepth 2 -type f -name '*.html' -not -path "*-doxy/*" -printf '%P\n' > /tmp/workspace/page_list.txt
102+
- store_artifacts:
103+
path: /tmp/workspace/page_list.txt
104+
105+
make_live:
106+
executor: doc_builder
107+
steps:
108+
- setup_aws_credentials
109+
- write_env_variables
110+
- run:
111+
name: Update live version on s3
112+
command: |
113+
source /tmp/env
114+
docbuilder set_live_version iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/$BUILD_DIRECTORY
115+
workflows:
116+
version: 2
117+
build-publish-zip-deploy:
118+
jobs:
119+
- build
120+
- publish_to_s3:
121+
requires:
122+
- build
123+
- push_redirects_to_s3:
124+
requires:
125+
- build
126+
- zip_documentation:
127+
requires:
128+
- build
129+
- list_pages:
130+
requires:
131+
- build
132+
- make_live:
133+
requires:
134+
- publish_to_s3

0 commit comments

Comments
 (0)