Merge pull request #5355 from dokku/autogenerate-docs
Autogenerate documentation in CI
This commit is contained in:
34
.github/workflows/docs.yml
vendored
Normal file
34
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
name: 'docs'
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cloning repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Generate documentation
|
||||
env:
|
||||
BOT_GITHUB_USERNAME: ${{ secrets.HOMEBREW_GITHUB_USERNAME }}
|
||||
BOT_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||
run: |
|
||||
git config --global user.name 'Dokku Bot'
|
||||
git config --global user.email no-reply@dokku.com
|
||||
|
||||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
||||
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
||||
sudo apt update
|
||||
sudo apt install gh -y
|
||||
|
||||
gh auth login --with-token <<<"$BOT_GITHUB_API_TOKEN"
|
||||
contrib/build-docs
|
||||
@@ -5,11 +5,14 @@ readonly ROOT_DIR="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)"
|
||||
|
||||
main() {
|
||||
pushd "$ROOT_DIR" >/dev/null || return 1
|
||||
rm -rf docs-main tmp/docs-source tmp/docs-build/docs # tmp/docs-build
|
||||
mkdir -p tmp/docs-build
|
||||
rm -rf docs-main tmp/docs-source tmp/docs-build # tmp/docs-build
|
||||
cp -r docs docs-main
|
||||
|
||||
echo "====> Fetching latest docs"
|
||||
git clone -q https://github.com/dokku/docs.git tmp/docs-build
|
||||
|
||||
echo "====> Processing version: latest"
|
||||
rm -rf tmp/docs-build/docs
|
||||
git clone -q https://github.com/dokku/dokku.git tmp/docs-source
|
||||
|
||||
rm -rf docs/assets
|
||||
@@ -110,9 +113,26 @@ main() {
|
||||
done
|
||||
|
||||
python contrib/sort-mkdocs-versions
|
||||
|
||||
echo "====> Cleanup main repo"
|
||||
rm -rf docs
|
||||
mv docs-main docs
|
||||
git checkout -- mkdocs.yml docs
|
||||
|
||||
if [[ "$(git -C tmp/docs-build ls-files -dmo)" == "docs/sitemap.xml.gz" ]]; then
|
||||
echo " ! No doc changes found"
|
||||
git -C tmp/docs-build checkout -- docs/sitemap.xml.gz
|
||||
else
|
||||
echo "====> Pushing docs"
|
||||
git -C tmp/docs-build add .
|
||||
git -C tmp/docs-build commit -m "chore: regenerate docs"
|
||||
|
||||
if [[ -n "$BOT_GITHUB_USERNAME" ]] && [[ -n "$BOT_GITHUB_API_TOKEN" ]]; then
|
||||
git -C tmp/docs-build remote set-url origin "https://$BOT_GITHUB_USERNAME:$BOT_GITHUB_API_TOKEN@github.com/dokku/docs.git"
|
||||
fi
|
||||
|
||||
git -C tmp/docs-build push origin master
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user