-
-
Notifications
You must be signed in to change notification settings - Fork 507
/
Copy pathupdate-search-index
executable file
·87 lines (72 loc) · 2.19 KB
/
update-search-index
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
echo "Welcome to the guided process of updating the Guides search index"
echo "We will now be running a mix of automated (🤖) and manual (👩💻) steps, please read the prompts carefully."
STARTING_BRANCH=$(git rev-parse --abbrev-ref HEAD)
TEMP_BRANCH="update-search-index-$(( $RANDOM % 1000 ))"
echo
echo "🤖 Staging local changes"
git add .
git stash push -m $TEMP_BRANCH
echo " DONE"
echo
echo "🤖 Updating master branch from remote"
read -p "Remote name (origin): " REMOTE
REMOTE_NAME=${REMOTE:-origin}
git fetch $REMOTE_NAME master
git checkout FETCH_HEAD -b $TEMP_BRANCH
echo
echo "🤖 Removing guides."
rm -rf ./guides/v?.*
echo " DONE"
echo
echo "🤖 Removing pre-built guides."
rm -rf ./public/v?.*
echo " DONE"
echo
echo "👩💻 Go to https://dashboard.algolia.com/account/api-keys/all?applicationId=Y1OMR4C7MF"
echo "👩💻 Copy the Write API Key with the copy button beside the obfuscated key and paste it below (note it won't seem like you're pasting)"
read -sp "Algolia Write API Key: " write_api_key
echo
echo "🤖 Writing ./config/credentials.json"
cat > ./config/credentials.json <<- EOF
{
"algoliaKey": "$write_api_key",
"algoliaIndex": "ember-guides",
"algoliaApplication": "Y1OMR4C7MF"
}
EOF
echo " DONE"
echo
echo "🤖 Pruning allVersions in ./guides/versions.yml"
CURRENT_VERSION=v$(cat ./guides/versions.yml | grep 'currentVersion' | grep -Eo "\d+.\d+.\d+")
VERSIONS_TAIL=$(cat ./guides/versions.yml | sed -n -e '/currentVersion/,$p')
cat > ./guides/versions.yml <<- EOF
allVersions:
- "$CURRENT_VERSION"
$VERSIONS_TAIL
EOF
echo " DONE"
echo
echo "🤖 Deleting versionsToIgnore in ./config/deploy.js"
sed -i '.bak' '/versionsToIgnore*/d' ./config/deploy.js
rm ./config/deploy.js.bak
echo " DONE"
echo
echo "🤖 Deleting dist folder"
rm -r dist
echo " DONE"
echo
echo "🤖 Deleting tmp folder"
rm -r tmp
echo " DONE"
echo
echo "🤖 Deploying"
ember deploy production
echo " DONE"
echo
echo "🤖 Restoring previous branch."
git reset --hard
git switch $STARTING_BRANCH
git stash list | grep $TEMP_BRANCH | grep -Eo '^[^:]+' | git stash pop -
git branch -D $TEMP_BRANCH
git stash pop "$(git stash list | grep $TEMP_BRANCH | grep -Eo '^[^:]+')"