Skip to content

chore(deps): update github actions (#446) #131

chore(deps): update github actions (#446)

chore(deps): update github actions (#446) #131

Workflow file for this run

name: Build Docs
permissions: {} # No permissions by default on workflow level
on:
workflow_dispatch: # run on request (no need for PR)
push:
branches:
- master
jobs:
Build-Docs:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
- name: Install dependencies
run: |
uv sync --locked --extra docs
- name: Build Docs
run: |
cd docs
uv run make html
- name: Branch name
id: branch_name
shell: bash
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
- name: Create gh-pages branch
env:
SOURCE: ${{steps.branch_name.outputs.SOURCE_NAME}}
run: |
if [[ ${{github.event_name}} == 'workflow_dispatch' ]]; then
echo RELEASE_VERSION="test_build" >> $GITHUB_ENV
else
echo RELEASE_VERSION=${GITHUB_REF#refs/*/} >> $GITHUB_ENV
fi
echo SOURCE_NAME=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
echo SOURCE_BRANCH=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT
echo SOURCE_TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
existed_in_remote=$(git ls-remote --heads origin gh-pages)
if [[ -z ${existed_in_remote} ]]; then
echo "Creating gh-pages branch"
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout --orphan gh-pages
git reset --hard
echo '<html><head><meta http-equiv="refresh" content="0; url=latest/" /></head></html>' > index.html
git add index.html
touch .nojekyll
git add .nojekyll
git commit -m "Initializing gh-pages branch"
git push origin gh-pages
git checkout "${SOURCE}"
echo "Created gh-pages branch"
else
echo "Branch gh-pages already exists"
fi
- name: Commit docs to gh-pages branch
env:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
run: |
git fetch
git checkout gh-pages
mkdir -p /tmp/docs_build
cp -r docs/build/html/* /tmp/docs_build/
rm -rf "$RELEASE_VERSION"/*
echo '<html><head><meta http-equiv="refresh" content="0; url=latest/" /></head></html>' > index.html
mkdir -p "$RELEASE_VERSION"
cp -r /tmp/docs_build/* ./"$RELEASE_VERSION"
rm -rf /tmp/docs_build
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if [[ "$RELEASE_VERSION" != 'test_build' ]]; then
ln -sfn "$RELEASE_VERSION" latest
fi
git add ./latest "$RELEASE_VERSION"
git add index.html
git commit -m "Update documentation" -a || true
- name: Push changes
uses: ad-m/github-push-action@57116acb309081ee57864270b0e3c4cedbe45452
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages