Skip to content

Commit

Permalink
docs(ci): Netlify ignore command to check branch
Browse files Browse the repository at this point in the history
Add a separate ignore script that checks git changes but also
only deploys main and version branches to allow us to deploy
versioned docs.
  • Loading branch information
petejohanson committed Nov 19, 2024
1 parent 4fcc308 commit af095fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docs/netlify-ignore-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# We deploy main and version branches only
if echo $HEAD | grep -E '^(main|v[[:digit:]]+\.([[:digit:]])+-branch)$' || echo $CONTEXT | grep '^deploy-preview$'
then
echo "Head '$HEAD' matches a deployed branch, or context is deploy preview, checking for git changes."
git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../app/boards/
else
echo "Head '$HEAD' does not match a deployed branch and is not a deploy preview"
exit 0
fi
2 changes: 1 addition & 1 deletion docs/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build]
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../app/boards/"
ignore = "bash ./netlify-ignore-command.sh"

[[redirects]]
from = "/community/discord/invite"
Expand Down

0 comments on commit af095fd

Please sign in to comment.