Skip to content

Commit 8c09645

Browse files
authored
fix: source TRACK from check_exists (IN-3577) (#372)
## Description If we use `TRACK_EXISTS` from `check_exists.sh` , we should re-use the track it checked
1 parent 371f23c commit 8c09645

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

src/scripts/docker/create_manifest.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ check_track_exist() {
1717
# Load TRACK_EXISTS variable from file previously stored in the tmp folder
1818
# shellcheck disable=SC1091
1919
source "/tmp/TRACK_STATUS"
20-
if [[ "$TRACK_EXISTS" != "true" && ! "$CIRCLE_BRANCH" =~ ^gtmq_ ]]; then
20+
21+
if [[ "$TRACK_EXISTS" != "true" ]]; then
2122
echo "Track does not exist! avoiding update!"
2223
exit 0
2324
fi
@@ -92,7 +93,6 @@ add_additional_tags() {
9293
update_track() {
9394
### update the track
9495
BUCKET="com.voiceflow.ci.assets"
95-
TRACK="tracks/${COMPONENT}/${CIRCLE_BRANCH}"
9696
echo "TRACK: $TRACK"
9797

9898
mkdir -p "$(dirname "/tmp/$TRACK")"

src/scripts/track/check_exists.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "${BUCKET?}"
77

88
BRANCH_NAME="$CIRCLE_BRANCH"
99
if [[ -z "$CIRCLE_BRANCH" && -n "$CIRCLE_TAG" ]]; then
10-
BRANCH_NAME="master"
10+
BRANCH_NAME="master"
1111
fi
1212

1313
TRACK="tracks/$COMPONENT/$BRANCH_NAME"
@@ -18,13 +18,18 @@ SEARCH_TRACK_RESULT=$?
1818
set -e
1919

2020
# Store the result on a file in tmp folder to use in future steps
21-
if [[ $SEARCH_TRACK_RESULT -eq 0 ]]; then
22-
echo 'export TRACK_EXISTS="true"' > /tmp/TRACK_STATUS # Track exists, skip following steps
21+
if [[ $SEARCH_TRACK_RESULT -eq 0 || "$CIRCLE_BRANCH" =~ ^gtmq_ ]]; then
22+
# Track exists, skip following steps
23+
cat <<-EOF >/tmp/TRACK_STATUS
24+
export TRACK_EXISTS="true"
25+
export TRACK="${TRACK}"
26+
EOF
27+
2328
else
24-
echo 'export TRACK_EXISTS="false"' > /tmp/TRACK_STATUS # Track exists, skip following steps
25-
if (( STOP )); then
26-
curl --request POST \
27-
--url "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/cancel" \
28-
--header "Circle-Token: ${CIRCLECI_API_TOKEN}"
29-
fi
29+
echo 'export TRACK_EXISTS="false"' >/tmp/TRACK_STATUS # Track does not exist
30+
if ((STOP)); then
31+
curl --request POST \
32+
--url "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/cancel" \
33+
--header "Circle-Token: ${CIRCLECI_API_TOKEN}"
34+
fi
3035
fi

src/scripts/track/update_track.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,10 @@ read -r -a EXTRA_BUILD_ARGS <<<"$EXTRA_BUILD_ARGS"
2626
# Load IMAGE_EXISTS variable from file previously stored in the tmp folder
2727
# shellcheck disable=SC1091
2828
source "/tmp/IMAGE_STATUS"
29-
# Load TRACK_EXISTS variable from file previously stored in the tmp folder
30-
# shellcheck disable=SC1091
31-
source "/tmp/TRACK_STATUS"
32-
33-
IS_GTMQ=$(grep -qE "^gtmq_" - <<<"${CIRCLE_BRANCH}" && echo 1 || echo 0)
3429

3530
if [[ "$TRACK_EXISTS" != "true" ]]; then
36-
if ((!IS_GTMQ)); then
37-
echo "Track does not exist! avoiding update!"
38-
exit 0
39-
fi
40-
41-
echo "Track will be created for merge queue branch"
42-
echo 'export TRACK_EXISTS="true"' >/tmp/TRACK_STATUS # Track exists, skip following steps
31+
echo "Track does not exist! avoiding update!"
32+
exit 0
4333
fi
4434

4535
if [[ -z "$CIRCLE_BRANCH" && -n "$CIRCLE_TAG" ]]; then
@@ -215,7 +205,6 @@ IMAGE_SHA="${IMAGE_SHA//sha256:/}"
215205
update_track() {
216206
### update the track
217207
BUCKET="com.voiceflow.ci.assets"
218-
TRACK="tracks/${COMPONENT}/${CIRCLE_BRANCH}"
219208
echo "TRACK: $TRACK"
220209

221210
mkdir -p "$(dirname "/tmp/$TRACK")"

0 commit comments

Comments
 (0)