Skip to content

Merge pull request #5 from acceleratescience/3-fix-diffusion-models-repo #9

Merge pull request #5 from acceleratescience/3-fix-diffusion-models-repo

Merge pull request #5 from acceleratescience/3-fix-diffusion-models-repo #9

Workflow file for this run

name: Deploy MkDocs to Documentation Repo
on:
push:
branches:
- main
repository_dispatch:
types: [rebuild_docs]
env:
PYTHON_VERSION: '3.x'
MKDOCS_SITE_DIR: 'site'
DOCS_BRANCH: 'gh-pages'
DOCS_SUBDIR: 'diffusion-models'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install MkDocs and dependencies
run: |
pip install mkdocs mkdocs-material mkdocstrings mkdocs-jupyter mkdocs-pdf
- name: Build the MkDocs site
run: mkdocs build
- name: Check if gh-pages branch exists
id: check_branch
run: |
if git ls-remote --heads origin gh-pages | grep -q 'refs/heads/gh-pages'; then
echo "Branch exists"
echo "branch_exists=true" >> $GITHUB_OUTPUT
else
echo "Branch does not exist"
echo "branch_exists=false" >> $GITHUB_OUTPUT
fi
- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: ${{ secrets.INSTALLATION_ID }}
- name: Clone the Documentation Repo
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git clone --branch ${{ env.DOCS_BRANCH }} https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/acceleratescience/resource-hub.git temp_docs
- name: Deploy to Documentation Repo
run: |
# Ensure the target directory exists
mkdir -p temp_docs/${{ env.DOCS_SUBDIR }}
# Sync the built site to the target directory
rsync -av --delete ${{ env.MKDOCS_SITE_DIR }}/ temp_docs/${{ env.DOCS_SUBDIR }}/
# Commit and push changes
cd temp_docs
git add .
git diff-index --quiet HEAD || (git stash && git pull --rebase origin ${{ env.DOCS_BRANCH }} && git stash pop)
git add .
git diff-index --quiet HEAD || git commit -m "Update ${{ env.DOCS_SUBDIR }} resource-hub"
git push origin ${{ env.DOCS_BRANCH }}
- name: Clean up
if: always()
run: |
rm -rf temp_docs