Merge branch 'feature/mr-docs-pages' into 'main'

Use GitLib exposed artifacts for third-party contributions

See merge request xmpp-rs/xmpp-rs!314
This commit is contained in:
Jonas Schäfer 2024-04-20 07:05:25 +00:00
commit f9a24aa301
1 changed files with 33 additions and 7 deletions

View File

@ -42,12 +42,28 @@ variables:
script:
- echo "Building docs to CI_DOC_TARGET=$CI_DOC_TARGET"
- cargo +nightly doc --no-deps -Zrustdoc-map
- apt install -y rsync openssh-client
- mkdir -p $HOME/.ssh
- echo -e "Host docs\n\tHostname docs.xmpp.rs\n\tPort 1312\n\tUser xmpp-rs\n\tStrictHostKeyChecking no" > $HOME/.ssh/config
- echo "$SECRET_DOCS_SSH_PRIVATE" > $HOME/.ssh/id_ed25519
- chmod 400 $HOME/.ssh/id_ed25519
- rsync -av target/doc/ docs:$CI_DOC_TARGET
- |
if [ -n "${SECRET_DOCS_SSH_PRIVATE:-}" ]; then
set -e
apt install -y rsync openssh-client
mkdir -p $HOME/.ssh
echo -e "Host docs\n\tHostname docs.xmpp.rs\n\tPort 1312\n\tUser xmpp-rs\n\tStrictHostKeyChecking no" > $HOME/.ssh/config
echo "$SECRET_DOCS_SSH_PRIVATE" > $HOME/.ssh/id_ed25519
chmod 400 $HOME/.ssh/id_ed25519
rsync -av target/doc/ docs:$CI_DOC_TARGET
# save artifact space
rm -rf -- target/doc/*
printf '<!DOCTYPE html><body><a href="%s">See here</a>' "$DOCS_BASEURL/$CI_MERGE_REQUEST_IID/" > target/doc/index.html
else
echo "$CI_JOB_ID" > target/doc/job_id.txt
fi
- mv target/doc/ public
artifacts:
expose_as: "Rendered Docs"
expire_in: "7 days"
# The trailing slash is required for exposure to work!
paths:
- public/
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
variables:
@ -87,9 +103,19 @@ docs:
bot-comment:
stage: bot
image: alpine:latest
dependencies:
- docs
script:
- apk add --no-cache glab
- glab mr --repo "$CI_MERGE_REQUEST_PROJECT_PATH" comment $CI_MERGE_REQUEST_IID --unique --message "Thanks for your MR! You can preview the docs [here]($DOCS_BASEURL/$CI_MERGE_REQUEST_IID/)."
- |
if [ -e "public/job_id.txt" ]; then
# CI build could not upload to docs.xmpp.rs, so we have to link to the job artifacts instead.
job_id="$(cat public/job_id.txt)"
docs_url="https://xmpp-rs.gitlab.io/-/xmpp-rs/-/jobs/$job_id/artifacts/public/xmpp/index.html"
else
docs_url="$DOCS_BASEURL/$CI_MERGE_REQUEST_IID/"
fi
- glab mr --repo "$CI_MERGE_REQUEST_PROJECT_PATH" comment $CI_MERGE_REQUEST_IID --unique --message "Thanks for your MR! You can preview the docs [here]($docs_url)."
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
variables: