-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50e550b
commit b712705
Showing
1 changed file
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} |