|
21 | 21 | # TODO: remove the install_gh call once circleci config is updated in all packs |
22 | 22 | type gh &>/dev/null || ~/ci/.circle/install_gh |
23 | 23 |
|
| 24 | +# GH_TOKEN is used by gh which is used in functions.sh |
| 25 | +export GH_TOKEN=${MACHINE_PASSWORD} |
| 26 | +source ~/ci/tools/functions.sh |
| 27 | + |
| 28 | +DEFAULT_BRANCH=$(_gh_default_branch) |
| 29 | +# Give a good error message after the first use of github API in this script. |
| 30 | +if [[ $? != 0 ]]; then |
| 31 | + echo "Error retrieving data with github graphql API." |
| 32 | + echo "The GitHub PAT might need to be regenerated:" |
| 33 | + echo "https://github.com/settings/tokens/new?scopes=public_repo&description=CircleCI%3A%20stackstorm-${PACK_NAME}" |
| 34 | +else |
| 35 | + echo "GitHub PAT is active." |
| 36 | +fi |
| 37 | + |
24 | 38 | # TODO: figure out how to make deploy.py rebuild the index. |
25 | 39 | # python ~/packs/.circle/deploy.py pack.yaml "${CIRCLE_PROJECT_REPONAME}" |
26 | 40 |
|
|
56 | 70 |
|
57 | 71 | # Afer pushing the version, make sure we check out the latest commit |
58 | 72 | # This is important so index reflects latest changes |
59 | | -git checkout master |
60 | | -git reset --hard master |
| 73 | +git checkout ${DEFAULT_BRANCH} |
| 74 | +git reset --hard ${DEFAULT_BRANCH} |
61 | 75 |
|
62 | 76 | # Verify there are no unstaged changes |
63 | 77 | git status |
@@ -96,8 +110,15 @@ if ! git -C ~/index diff --quiet --exit-code --cached |
96 | 110 | then |
97 | 111 | echo "Updating the index repo..." |
98 | 112 | git -C ~/index commit -m "Update the ${PACK_NAME} pack." |
99 | | - git -C ~/index push -q origin |
100 | | - echo "Index updated." |
| 113 | + if [[ ${DO_NOT_ADD_TO_EXCHANGE_INDEX:-false} == "true" ]]; then |
| 114 | + echo "Normal packs update the Exchange index at this point." |
| 115 | + echo "This pack will not be added to the Exchange index because of this env var:" |
| 116 | + echo "DO_NOT_ADD_TO_EXCHANGE_INDEX=${DO_NOT_ADD_TO_EXCHANGE_INDEX}" |
| 117 | + echo "(This var should only be set per-repo in the CI system's UI.)" |
| 118 | + else |
| 119 | + git -C ~/index push -q origin |
| 120 | + echo "Index updated." |
| 121 | + fi |
101 | 122 |
|
102 | 123 | # echo "Updating the repo description..." |
103 | 124 | # PACK_DESCRIPTION=$(cat ~/index/v1/index.json | jq ".packs.${PACK_NAME}.description") |
|
0 commit comments