aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2025-10-13 19:27:30 -0400
committerEugene Triguba <hello@eugenetriguba.com>2025-10-13 19:37:52 -0400
commit94442fa6454bdf68d2e570d81e1122d98c1103a8 (patch)
treeaf15adf58b274def86613fb066653b05409551e1
parentUpdate build docs for contributing guide (diff)
downloadcli-94442fa6454bdf68d2e570d81e1122d98c1103a8.zip
Add is-branch main check for docs deployment
-rw-r--r--.builds/docs.yml4
-rwxr-xr-xscripts/is-branch.sh39
2 files changed, 42 insertions, 1 deletions
diff --git a/.builds/docs.yml b/.builds/docs.yml
index 8338fd6..047f21b 100644
--- a/.builds/docs.yml
+++ b/.builds/docs.yml
@@ -17,4 +17,6 @@ triggers:
tasks:
- deploy: |
cd bolt
- ./scripts/deploy-docs.sh
+ if ./scripts/is-branch.sh "main"; then
+ ./scripts/deploy-docs.sh
+ fi
diff --git a/scripts/is-branch.sh b/scripts/is-branch.sh
new file mode 100755
index 0000000..7bba709
--- /dev/null
+++ b/scripts/is-branch.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+set -eou pipefail
+
+source "$(dirname "${BASH_SOURCE[0]}")/lib/log.sh"
+
+TARGET_BRANCH=""
+
+main() {
+ if [[ $# -ne 1 ]]; then
+ echo "Usage: $0 <target-branch>" >&2
+ exit 1
+ fi
+ TARGET_BRANCH="$1"
+ local -r current_branch=$(get_current_branch)
+
+ if [[ "$current_branch" != "$TARGET_BRANCH" ]]; then
+ log_warn "Not on $TARGET_BRANCH branch (current branch is $current_branch)"
+ exit 2
+ fi
+ log_info "On $TARGET_BRANCH branch"
+}
+
+get_current_branch() {
+ # build.sr.ht automatically injects the GIT_REF environment variable
+ # - GIT_REF: Git reference which triggered the build (e.g. refs/heads/master)
+ #
+ # See https://man.sr.ht/builds.sr.ht/
+ local current_branch="${GIT_REF:-}"
+ if [[ -z "$current_branch" ]]; then
+ current_branch=$(git rev-parse --abbrev-ref HEAD)
+ else
+ # Strip refs/heads/ prefix if present
+ # GIT_REF, if set, should be in the format: refs/heads/<branch-name>
+ current_branch="${current_branch#refs/heads/}"
+ fi
+ echo "$current_branch"
+}
+
+main "$@"