Skip to content

Commit

Permalink
feat: track toggle (#265)
Browse files Browse the repository at this point in the history
* feat: track toggle

* fix: remove odd jobs
  • Loading branch information
xavidop committed Jul 9, 2024
1 parent a0355c7 commit 5d3541d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/commands/track/update_track.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ parameters:
description: named builder for use with DLC
type: string
default: ""
update_track_file:
description: Determines if the track file will be updated or not
type: boolean
default: true
steps:
- when:
condition: << parameters.checkout >>
Expand Down Expand Up @@ -143,4 +147,5 @@ steps:
ENABLE_LOAD: "<< parameters.enable_load >>"
PLATFORM: "<< parameters.platform >>"
BUILDER_NAME: "<< parameters.builder_name >>"
UPDATE_TRACK_FILE: << parameters.update_track_file >>
command: <<include(scripts/track/update_track.sh)>>
5 changes: 5 additions & 0 deletions src/jobs/track/update_track.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ parameters:
description: named builder for use with DLC
type: string
default: ""
update_track_file:
description: Determines if the track file will be updated or not
type: boolean
default: true
steps:
- update_track:
image_repo: "<< parameters.image_repo >>"
Expand All @@ -120,3 +124,4 @@ steps:
enable_dlc: "<< parameters.enable_dlc >>"
enable_load: "<< parameters.enable_load >>"
builder_name: "<< parameters.builder_name >>"
update_track_file: "<< parameters.update_track_file >>"
21 changes: 14 additions & 7 deletions src/scripts/track/update_track.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ echo "BUILDER_NAME: ${BUILDER_NAME-}"
echo "EXTRA_BUILD_ARGS: ${EXTRA_BUILD_ARGS[*]}"
echo "ENABLE_CACHE_TO: ${ENABLE_CACHE_TO:=0}"
echo "ENABLE_LOAD: ${ENABLE_LOAD:=0}"
echo "UPDATE_TRACK_FILE: ${UPDATE_TRACK_FILE:=0}"


# force string to array
read -r -a EXTRA_BUILD_ARGS <<< "$EXTRA_BUILD_ARGS"
Expand Down Expand Up @@ -149,11 +151,16 @@ IMAGE_SHA=$(crane digest "$IMAGE_NAME")
# Remove the sha256: string
IMAGE_SHA="${IMAGE_SHA//sha256:/}"

# update the track
TRACK="tracks/$COMPONENT/$CIRCLE_BRANCH"
echo "TRACK: $TRACK"
if (( UPDATE_TRACK_FILE )); then
# update the track
TRACK="tracks/$COMPONENT/$CIRCLE_BRANCH"
echo "TRACK: $TRACK"

# the file /tmp/$TRACK is downloaded in the check_track_exists step
yq -y -i --arg tag "${IMAGE_TAG}" ".\"$COMPONENT\".image.tag=\$tag" "/tmp/$TRACK"
yq -y -i --arg sha "${IMAGE_SHA}" ".\"$COMPONENT\".image.sha=\$sha" "/tmp/$TRACK"
aws s3 cp "/tmp/$TRACK" "s3://$BUCKET/$TRACK"
else
echo "Skipping track update"
fi

# the file /tmp/$TRACK is downloaded in the check_track_exists step
yq -y -i --arg tag "${IMAGE_TAG}" ".\"$COMPONENT\".image.tag=\$tag" "/tmp/$TRACK"
yq -y -i --arg sha "${IMAGE_SHA}" ".\"$COMPONENT\".image.sha=\$sha" "/tmp/$TRACK"
aws s3 cp "/tmp/$TRACK" "s3://$BUCKET/$TRACK"

0 comments on commit 5d3541d

Please sign in to comment.