Skip to content

Commit

Permalink
🩹 Fix docs build (#1307)
Browse files Browse the repository at this point in the history
* Modify workflow

* use self hosted runner

* quotes python version

* pre-commit whitespace

* revert cp stage

---------

Co-authored-by: Ashwin Vaidya <[email protected]>
Co-authored-by: Samet Akcay <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2023
1 parent 4458fd1 commit f3e2938
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
67 changes: 31 additions & 36 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,61 @@ on:
workflow_dispatch: # run on request (no need for PR)

permissions:
contents: write
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
Build-and-Publish-Documentation:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: [docs]
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install requirements
run: |
pip install -r requirements/docs.txt
pip install .[full]
pip install ".[full]"
- name: Link dataset path to local directory as nbsphinx runs the notebook
run: ln -s $ANOMALIB_DATASET_PATH ./datasets
- name: Build and Commit Docs
run: |
cd docs
make html
- name: Create gh-pages branch
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
cd ..
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
touch .nojekyll
git add .nojekyll
git commit -m "Initializing gh-pages branch"
git push origin gh-pages
git checkout ${{steps.branch_name.outputs.SOURCE_NAME}}
echo "Created gh-pages branch"
else
echo "Branch gh-pages already exists"
fi
- name: Commit docs to gh-pages branch
- name: Clean directory
run: |
git fetch
git checkout gh-pages
mkdir -p /tmp/docs_build
cp -r docs/build/html/* /tmp/docs_build/
rm -rf ./*
cp -r /tmp/docs_build/* ./
rm -rf /tmp/docs_build
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
- name: Push changes
uses: ad-m/github-push-action@master
touch .nojekyll
- name: Setup Pages
uses: actions/configure-pages@v2

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
# Upload entire repository
path: "."

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ dataset:
normalization: imagenet # data distribution to which the images will be normalized: [none, imagenet]
test_split_mode: from_dir # options: [from_dir, synthetic]
val_split_mode: same_as_test # options: [same_as_test, from_test, sythetic]
val_split_ratio: 0.5 # fraction of train/test images held out for validation (usage depends on val_split_mode)
val_split_ratio: 0.5 # fraction of train/test images held out for validation (usage depends on val_split_mode)
transform_config:
train: null
val: null
Expand Down

0 comments on commit f3e2938

Please sign in to comment.