Skip to content

Commit

Permalink
Clean up publish docs script
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephusPaye committed Apr 8, 2023
1 parent 9c4212e commit 97fad1d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/publish-docs-next.sh
@@ -1,30 +1,30 @@
# Exit on first error, treat unset variables as errors
set -eu

NEXT_BRANCH="paye/auto-publish-docs" # TODO: Change this to `next` before merging
GH_PAGES_BRANCH="gh-pages"
BRANCH_NEXT="paye/auto-publish-docs" # TODO: Change this to `next` before merging
BRANCH_GH_PAGES="gh-pages"

echo "NEXT_BRANCH: $NEXT_BRANCH"
echo "GH_PAGES_BRANCH: $GH_PAGES_BRANCH"
echo "BRANCH_NEXT: $BRANCH_NEXT"
echo "BRANCH_GH_PAGES: $BRANCH_GH_PAGES"

# Exit if the current branch is not `next`
if [[ $(git rev-parse --abbrev-ref HEAD) != "$NEXT_BRANCH" ]]; then
echo "This script can only be run on the $NEXT_BRANCH branch."
# Exit if the current branch is not the next branch
if [[ $(git rev-parse --abbrev-ref HEAD) != "$BRANCH_NEXT" ]]; then
echo "This script can only be run on the $BRANCH_NEXT branch."
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
exit 1
fi

# Keep track of the current commit sha
NEXT_LAST_COMMIT=$(git rev-parse --short HEAD)
echo "NEXT_LAST_COMMIT: $NEXT_LAST_COMMIT"
LAST_COMMIT_ON_NEXT=$(git rev-parse --short HEAD)
echo "LAST_COMMIT_ON_NEXT: $LAST_COMMIT_ON_NEXT"

echo ""
echo "Building docs..."
yarn build:docs

echo ""
echo "Switching to the $GH_PAGES_BRANCH branch..."
git checkout $GH_PAGES_BRANCH
echo "Switching to the $BRANCH_GH_PAGES branch..."
git checkout $BRANCH_GH_PAGES

echo ""
echo "Replacing the existing \`next\` docs with a copy of the new docs..."
Expand All @@ -36,11 +36,11 @@ if ! git diff --quiet -- next/; then
echo "Committing the changes..."
git add next/
git -c user.name="Josephus Paye II" -c user.email="j.paye96@gmail.com" \
commit -m "Add \`next\` docs for commit $NEXT_LAST_COMMIT"
commit -m "Add \`next\` docs for commit $LAST_COMMIT_ON_NEXT"

echo ""
echo "Pushing the changes to the $GH_PAGES_BRANCH branch..."
git push origin $GH_PAGES_BRANCH
echo "Pushing the changes to the $BRANCH_GH_PAGES branch..."
git push origin $BRANCH_GH_PAGES
else
echo ""
echo "No changes to built docs, skipping publish"
Expand Down

0 comments on commit 97fad1d

Please sign in to comment.