Skip to content

Update CircleCI config for branch "development" #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .circleci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docs CI config

This is the CircleCI config for building documentation from docs repos.

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.


## Making changes to the config

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.

134 changes: 134 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
version: 2.1

references:
workspace_root: &workspace_root /tmp/workspace
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

executors:
doc_builder:
docker:
- image: mbed/doc_builder:latest
auth:
username: $DOCKER_USER
password: $DOCKER_PASS

commands:
setup_aws_credentials:
description: "Setup AWS credentials"
steps:
- run:
name: Write credentials to ~/.aws/credentials
command: |
mkdir ~/.aws
echo -e "[default]\naws_access_key_id=$AWS_PROD_ACCESS_KEY_ID\naws_secret_access_key=$AWS_PROD_SECRET_KEY\n" > ~/.aws/credentials
write_env_variables:
description: "Write ENV variables"
steps:
- run:
command: |
echo "export CIRCLE_BRANCH_NO_SLASH=$(echo $CIRCLE_BRANCH|sed 's/\//-/')" >> /tmp/env
echo "export BUILD_DIRECTORY=$CIRCLE_SHA1-$CIRCLE_WORKFLOW_ID" >> /tmp/env
jobs:
build:
executor: doc_builder
steps:
- checkout
- setup_aws_credentials
- write_env_variables
- run:
name: Validate redirects
command: |
if [ -f "$HOME/project/redirects.json" ]; then
python -mjson.tool "$HOME/project/redirects.json" > /dev/null
fi
- run:
name: Validate and build documentation
command: |
source /tmp/env
docbuilder build $CIRCLE_BRANCH_NO_SLASH /tmp/workspace/artifacts --path ~/project/docs.json --github_token "$GITHUB_TOKEN"
- persist_to_workspace:
root: *workspace_root
paths:
- artifacts

publish_to_s3:
executor: doc_builder
steps:
- setup_aws_credentials
- write_env_variables
- *attach_workspace
- run:
name: Upload documentation to s3
command: |
source /tmp/env
docbuilder publish /tmp/workspace/artifacts/$CIRCLE_BRANCH_NO_SLASH iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/$BUILD_DIRECTORY
push_redirects_to_s3:
executor: doc_builder
steps:
- checkout
- setup_aws_credentials
- write_env_variables
- *attach_workspace
- run:
name: Upload redirects.json to s3
command: |
source /tmp/env
docbuilder upload_file ~/project/redirects.json iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/redirects.json
zip_documentation:
machine: true
steps:
- *attach_workspace
- run:
name: Zip built documentation
command: |
cd /tmp/workspace/artifacts
zip -r /tmp/workspace/docs.zip .
- store_artifacts:
path: /tmp/workspace/docs.zip

list_pages:
machine: true
steps:
- write_env_variables
- *attach_workspace
- run:
name: List all built docs pages
command: |
source /tmp/env
cd /tmp/workspace/artifacts/$CIRCLE_BRANCH_NO_SLASH
find -maxdepth 2 -type f -name '*.html' -not -path "*-doxy/*" -printf '%P\n' > /tmp/workspace/page_list.txt
- store_artifacts:
path: /tmp/workspace/page_list.txt

make_live:
executor: doc_builder
steps:
- setup_aws_credentials
- write_env_variables
- run:
name: Update live version on s3
command: |
source /tmp/env
docbuilder set_live_version iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/$BUILD_DIRECTORY
workflows:
version: 2
build-publish-zip-deploy:
jobs:
- build
- publish_to_s3:
requires:
- build
- push_redirects_to_s3:
requires:
- build
- zip_documentation:
requires:
- build
- list_pages:
requires:
- build
- make_live:
requires:
- publish_to_s3