Skip to content

fix: merge conflict #80

fix: merge conflict

fix: merge conflict #80

name: Build & Update Docs
on:
push:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Determine branch/tag and set git author
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
CURBRANCH=${GITHUB_REF##*/}
BUILD_TYPE="tag"
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
CURBRANCH=${GITHUB_REF##*/}
BUILD_TYPE="branch"
else
CURBRANCH="unknown"
BUILD_TYPE="unknown"
fi
CURBRANCH=$( echo "$CURBRANCH" | sed 's+/+_+g' )
echo "Building branch/tag ${CURBRANCH:-<unknown>}, from git ref <$GITHUB_REF>"
echo "CURBRANCH=${CURBRANCH}" >> "${GITHUB_ENV}"
echo "BUILD_TYPE=${BUILD_TYPE}" >> "${GITHUB_ENV}"
git config user.email "[email protected]"
git config user.name "nxbench bot"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[doc]
- name: Build docs
run: |
make clean_doc
make doc_html
- name: Create Redirect
run: |
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=main/index.html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>nxbench Documentation</title>
</head>
<body>
<p>If you are not redirected, <a href="main/index.html">click here</a>.</p>
</body>
</html>' > index.html
- name: Deploy to gh-pages
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: |
git stash --include-untracked
git fetch origin gh-pages
git checkout gh-pages || git checkout --orphan gh-pages
if [[ "${BUILD_TYPE}" == "branch" && "${CURBRANCH}" == "main" ]]; then
git rm -rf main/ || true
elif [[ "${BUILD_TYPE}" == "tag" ]]; then
git rm -rf "${CURBRANCH}/" || true
fi
if [[ "${BUILD_TYPE}" == "branch" && "${CURBRANCH}" == "main" ]]; then
mkdir -p main/
cp -r doc/build/html/* main/
elif [[ "${BUILD_TYPE}" == "tag" ]]; then
mkdir -p "${CURBRANCH}/"
cp -r doc/build/html/* "${CURBRANCH}/"
fi
git checkout gh-pages -- index.html || true
git add .
git commit -m "doc: Update documentation for ${CURBRANCH}" || true
git push origin gh-pages