forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish_onboarding_sync_branch.sh
More file actions
executable file
·49 lines (38 loc) · 1.09 KB
/
Copy pathpublish_onboarding_sync_branch.sh
File metadata and controls
executable file
·49 lines (38 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "usage: $0 <bundle-dir> [branch]" >&2
exit 1
fi
BUNDLE_DIR=$1
TARGET_BRANCH=${2:-figma-onboarding-sync}
if [[ ! -d "$BUNDLE_DIR" ]]; then
echo "bundle directory not found: $BUNDLE_DIR" >&2
exit 1
fi
if [[ -z "${GITHUB_REPOSITORY:-}" ]]; then
echo "GITHUB_REPOSITORY must be set" >&2
exit 1
fi
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
echo "GITHUB_TOKEN must be set" >&2
exit 1
fi
TMP_DIR=$(mktemp -d)
PUBLISH_DIR="$TMP_DIR/publish"
mkdir -p "$PUBLISH_DIR/onboarding/latest"
cleanup() {
rm -rf "$TMP_DIR"
}
trap cleanup EXIT
cp -R "$BUNDLE_DIR"/. "$PUBLISH_DIR/onboarding/latest/"
touch "$PUBLISH_DIR/.nojekyll"
cd "$PUBLISH_DIR"
git init -q
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b "$TARGET_BRANCH" >/dev/null 2>&1
git add .
git commit -m "Update onboarding sync bundle" >/dev/null
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push --force origin "HEAD:${TARGET_BRANCH}"