nim-libp2p/.github/workflows/documentation.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

112 lines
2.9 KiB
YAML
Raw Normal View History

name: Documentation Generation And Publishing
2022-07-01 18:19:57 +00:00
on:
push:
2024-06-19 14:40:01 +00:00
branches:
- master
2022-07-01 18:19:57 +00:00
workflow_dispatch:
jobs:
build:
timeout-minutes: 20
name: 'Generate & upload documentation'
runs-on: ubuntu-latest
2022-07-01 18:19:57 +00:00
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
2022-07-01 18:19:57 +00:00
with:
submodules: true
- uses: jiro4989/setup-nim-action@v1
with:
2023-11-16 14:58:05 +00:00
nim-version: '1.6.x'
2022-07-01 18:19:57 +00:00
- name: Generate doc
run: |
nim --version
nimble --version
2023-11-16 14:58:05 +00:00
nimble install_pinned
2022-07-01 18:19:57 +00:00
# nim doc can "fail", but the doc is still generated
2024-06-19 14:40:01 +00:00
nim doc --git.url:https://github.com/vacp2p/nim-libp2p --git.commit:${GITHUB_REF##*/} --outdir:${GITHUB_REF##*/} --project libp2p || true
2022-07-01 18:19:57 +00:00
# check that the folder exists
ls ${GITHUB_REF##*/}
- name: Clone the gh-pages branch
uses: actions/checkout@v4
2022-07-01 18:19:57 +00:00
with:
2024-06-19 14:40:01 +00:00
repository: vacp2p/nim-libp2p
2022-07-01 18:19:57 +00:00
ref: gh-pages
path: subdoc
submodules: true
fetch-depth: 0
- name: Commit & push
run: |
cd subdoc
# Update / create this branch doc
rm -rf ${GITHUB_REF##*/}
mv ../${GITHUB_REF##*/} .
# Remove .idx files
# NOTE: git also uses idx files in his
# internal folder, hence the `*` instead of `.`
find * -name "*.idx" -delete
git add .
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name = "${{ github.actor }}"
git commit -a -m "update docs for ${GITHUB_REF##*/}"
git push origin gh-pages
2022-07-26 10:44:26 +00:00
update_site:
name: 'Rebuild website'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
2022-07-26 10:44:26 +00:00
- uses: actions/setup-python@v2
with:
python-version: 3.x
2022-09-28 08:40:53 +00:00
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: 'stable'
2022-07-26 10:44:26 +00:00
- name: Generate website
2024-06-13 13:28:47 +00:00
run: pip install mkdocs-material && nimble -y website
2022-07-26 10:44:26 +00:00
- name: Clone the gh-pages branch
uses: actions/checkout@v4
2022-07-26 10:44:26 +00:00
with:
2024-06-13 13:28:47 +00:00
repository: vacp2p/nim-libp2p
2022-07-26 10:44:26 +00:00
ref: gh-pages
path: subdoc
fetch-depth: 0
- name: Commit & push
run: |
cd subdoc
2024-06-19 14:40:01 +00:00
# Ensure the latest changes are fetched and reset to the remote branch
git fetch origin gh-pages
git reset --hard origin/gh-pages
2022-07-26 10:44:26 +00:00
rm -rf docs
mv ../site docs
git add .
2024-06-19 14:40:01 +00:00
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git commit -m "update website"
git push origin gh-pages
fi