-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into daterange-picker
- Loading branch information
Showing
53 changed files
with
25,021 additions
and
17,592 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
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Exit on first error, treat unset variables as errors | ||
set -eu | ||
|
||
BRANCH_NEXT="next" | ||
BRANCH_GH_PAGES="gh-pages" | ||
|
||
echo "BRANCH_NEXT: $BRANCH_NEXT" | ||
echo "BRANCH_GH_PAGES: $BRANCH_GH_PAGES" | ||
|
||
# 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 | ||
LAST_COMMIT_ON_NEXT=$(git rev-parse --short HEAD) | ||
echo "LAST_COMMIT_ON_NEXT: $LAST_COMMIT_ON_NEXT" | ||
|
||
# Change the version to "next" before building the docs | ||
echo "export default \"next\";" > ./build/version.mjs | ||
|
||
echo "" | ||
echo "Building docs..." | ||
yarn build:docs | ||
|
||
# Undo the change to the version, to switch branches | ||
git checkout -- ./build/version.mjs | ||
|
||
echo "" | ||
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..." | ||
rm -rf next && mv docs/ next/ | ||
|
||
# The built files have links to the `master` branch on GitHub. | ||
# Find and replace those links to point to the next branch. Replace: | ||
# - `/tree/master` with `/tree/$BRANCH_NEXT` | ||
# - `/blob/master` with `/blob/$BRANCH_NEXT` | ||
echo "" | ||
echo "Replacing links to \`master\` with links to \`$BRANCH_NEXT\`..." | ||
BRANCH_NEXT_SLASH_ESCAPED=$(echo "$BRANCH_NEXT" | sed 's/\//\\\//g') | ||
find next/ -type f -exec sed -i -e "s/\/tree\/master/\/tree\/$BRANCH_NEXT_SLASH_ESCAPED/g" {} \; | ||
find next/ -type f -exec sed -i -e "s/\/blob\/master/\/blob\/$BRANCH_NEXT_SLASH_ESCAPED/g" {} \; | ||
|
||
# If there are changes in the built docs, commit and push them | ||
if ! git diff --quiet -- next/; then | ||
echo "" | ||
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 $LAST_COMMIT_ON_NEXT" | ||
|
||
echo "" | ||
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" | ||
exit 0 | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Publish docs for `next` branch | ||
|
||
on: | ||
push: | ||
branches: [next] | ||
|
||
# Used to ensure only one instance of the workflow is running at a time, cancels existing runs when there's a new one. | ||
# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency. | ||
concurrency: | ||
# `github.workflow` is workflow name, `github.ref` is current branch/tag identifier | ||
group: ${{ format('{0}:{1}', github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check_for_changes: | ||
name: Check for changes | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
has_workflow_changes: ${{ steps.filter.outputs.workflow_changes }} | ||
has_docs_changes: ${{ steps.filter.outputs.docs_changes }} | ||
has_src_changes: ${{ steps.filter.outputs.src_changes }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
- name: Check for Changes | ||
uses: dorny/paths-filter@v2 | ||
id: filter | ||
with: | ||
filters: | | ||
workflow_changes: | ||
- '.github/workflows/publish-docs-next*' | ||
docs_changes: | ||
- 'docs-src/**' | ||
src_changes: | ||
- 'src/**' | ||
publish_docs: | ||
name: "Build and publish docs to GitHub Pages" | ||
runs-on: "ubuntu-latest" | ||
needs: ["check_for_changes"] | ||
if: | | ||
needs.check_for_changes.outputs.has_workflow_changes == 'true' || | ||
needs.check_for_changes.outputs.has_docs_changes == 'true' || | ||
needs.check_for_changes.outputs.has_src_changes == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: next | ||
fetch-depth: 0 # fetch all history so we can switch branches to `gh-pages` | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "yarn" | ||
- run: yarn install --frozen-lockfile | ||
- run: bash .github/workflows/publish-docs-next.sh |
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ _reminder | |
Thumbs.db | ||
npm-debug.log | ||
.DS_Store | ||
docs |
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
Oops, something went wrong.