-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
update_qualityjson.sh
executable file
·33 lines (24 loc) · 1.06 KB
/
update_qualityjson.sh
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
#!/usr/bin/env bash
set -e
if [[ "${SHOULD_BUILD}" != "yes" ]]; then
echo "Will not update version JSON because we did not build"
exit 0
fi
if [[ -z "${GH_TOKEN}" ]] && [[ -z "${GITHUB_TOKEN}" ]] && [[ -z "${GH_ENTERPRISE_TOKEN}" ]] && [[ -z "${GITHUB_ENTERPRISE_TOKEN}" ]]; then
echo "Will not update ${VSCODE_QUALITY}.json because no GITHUB_TOKEN defined"
exit 0
fi
jsonTmp=$( cat "${VSCODE_QUALITY}.json" | jq --arg 'tag' "${MS_TAG/\-insider/}" --arg 'commit' "${MS_COMMIT}" '. | .tag=$tag | .commit=$commit' )
echo "${jsonTmp}" > "${VSCODE_QUALITY}.json" && unset jsonTmp
git config user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )[email protected]"
git config user.name "${GITHUB_USERNAME} CI"
git add .
CHANGES=$( git status --porcelain )
if [[ -n "${CHANGES}" ]]; then
git commit -m "build(${VSCODE_QUALITY}): update to commit ${MS_COMMIT:0:7}"
BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD )
if ! git push origin "${BRANCH_NAME}" --quiet; then
git pull origin "${BRANCH_NAME}"
git push origin "${BRANCH_NAME}" --quiet
fi
fi