Skip to content

Commit

Permalink
Fix deploy of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pablormier committed May 12, 2024
1 parent 50e550b commit b712705
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,29 @@ jobs:
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Create a temporary directory
TEMP_DIR=$(mktemp -d)
echo "Temporary directory is $TEMP_DIR"
# Build and prepare all the files first
mkdir -p "$TEMP_DIR/$BRANCH_NAME"
cp -r "docs/_build/html/." "$TEMP_DIR/$BRANCH_NAME/"
# Now checkout to gh-pages
git fetch origin gh-pages
git checkout gh-pages || git checkout --orphan gh-pages
# Get the name of the branch that triggered the workflow
BRANCH_NAME=${GITHUB_REF#refs/heads/}
echo "Deploying documentation for branch: $BRANCH_NAME"
# Removing old files
# Clean existing files for the branch and copy new ones
rm -rf "./$BRANCH_NAME"
mkdir -p "./$BRANCH_NAME"

# Copying new files
cp -r "docs/_build/html/$BRANCH_NAME/." "./$BRANCH_NAME/"
cp -r "$TEMP_DIR/$BRANCH_NAME/." "./$BRANCH_NAME/"

# Adding changes to git
git add .
git commit -m "Update docs for branch $BRANCH_NAME"
git commit -m "Update docs for branch $BRANCH_NAME" --allow-empty
git push -u origin gh-pages

# Optionally, remove the temporary directory (not necessary on CI environments)
# rm -rf "$TEMP_DIR"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit b712705

Please sign in to comment.