Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

CI: publish rustdocs #9527

Merged
merged 14 commits into from
Aug 12, 2021
60 changes: 41 additions & 19 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,10 @@ build-rust-doc:
time cargo +nightly doc --no-deps --workspace --all-features --verbose
- rm -f ./target/doc/.lock
- mv ./target/doc ./crate-docs
# FIXME: remove me after CI image gets nonroot
- chown -R nonroot:nonroot ./crate-docs
- echo "<meta http-equiv=refresh content=0;url=sc_service/index.html>" > ./crate-docs/index.html
- sccache -s
allow_failure: true

#### stage: publish

Expand Down Expand Up @@ -641,32 +642,53 @@ publish-s3-release:
- aws s3 ls s3://${BUCKET}/${PREFIX}/latest/
--recursive --human-readable --summarize

publish-s3-doc:
publish-docs:
stage: publish
image: paritytech/awscli:latest
allow_failure: true
<<: *kubernetes-env
image: paritytech/tools:latest
needs:
- job: build-rust-doc
artifacts: true
- job: build-linux-substrate
artifacts: false
<<: *build-refs
<<: *kubernetes-env
variables:
GIT_STRATEGY: none
BUCKET: "releases.parity.io"
PREFIX: "substrate-rustdoc"
script:
- test -r ./crate-docs/index.html || (
echo "./crate-docs/index.html not present, build:rust:doc:release job not complete";
exit 1
)
- ls -lah crate-docs
- aws s3 sync --delete --size-only --only-show-errors
./crate-docs/ s3://${BUCKET}/${PREFIX}/
GIT_DEPTH: 100
rules:
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: never
- if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "master"
before_script:
- unset CARGO_TARGET_DIR
script:
- rm -rf /tmp/*
# Set git config
- rm -rf .git/config
- git config user.email "devops-team@parity.io"
- git config user.name "${GITHUB_USER}"
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/substrate.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin gh-pages
# saving README and docs
- cp -r ./crate-docs/ /tmp/doc/
- cp README.md /tmp/doc/
- cp -r .images/ /tmp/doc/
- git checkout gh-pages
# remove everything and restore generated docs, README and Jekyll config
- rm -rf ./*
- mv /tmp/doc/* .
# Upload files
- git add --all --force
# `git commit` has an exit code of > 0 if there is nothing to commit.
# This unfortunately causes GitLab to exit immediately and mark this
# job as failed subsequently.
# We don't want to mark the entire job as failed if there's nothing to
# publish though, hence the `|| true`.
- git commit -m "Updated docs for ${CI_COMMIT_REF_NAME}" ||
echo "___Nothing to commit___"
- git push origin gh-pages --force
after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/
--human-readable --summarize
- rm -rf .git/ ./*

publish-draft-release:
stage: publish
Expand Down