Skip to content

Commit b9c7fd8

Browse files
committed
add-credentials on preview --init
(unless ~/.git-credentials already exists)
1 parent e78e1cb commit b9c7fd8

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

scripts/add-credentials

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/bash
22

33
CRED=~/.git-credentials
4-
cp $CRED $CRED.backup # if it exists
4+
5+
if [ -f $CRED ]; then
6+
BACKUP=$CRED.backup
7+
mv $CRED $BACKUP
8+
echo "Backed up credentials to $BACKUP"
9+
fi
510

611
set -euo pipefail
712
USER=$(gh api user -q .login)

scripts/preview

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
PREVIEW_VERSION="1.1.0"
2+
PREVIEW_VERSION="1.1.1"
33

44
set -eo pipefail
55
echo "🐇 Hello! I'm the Docs Build Rabbit"
@@ -128,8 +128,9 @@ while [[ $# -gt 0 ]]; do
128128
esac
129129
done
130130

131+
DOCS_SITE=$(realpath $0/../..)
132+
131133
if [ -n "$UPDATE" ]; then
132-
DOCS_SITE=$(realpath $0/../..)
133134
cd $DOCS_SITE
134135

135136
echo "🐇 Let's try to update preview, by updating your docs-site checkout"
@@ -155,6 +156,17 @@ if [ -n "$INIT" ]; then
155156
brew install gh jq yq
156157
gh auth token || gh auth login
157158

159+
if [ ! -f ~/.git-credentials ]; then
160+
scripts/add-credentials
161+
else
162+
echo "Git credentials found, let's assume they are good."
163+
echo "If you get errors cloning private repos, then try running:"
164+
echo
165+
echo " cd $DOCS_SITE"
166+
echo " scripts/add-credentials"
167+
echo
168+
fi
169+
158170
echo "🐇 initialised preview script"
159171
exit 0
160172
fi

0 commit comments

Comments
 (0)