From f03dca82a3a67225650ca2652a419b2d65e5a171 Mon Sep 17 00:00:00 2001 From: kcelia Date: Thu, 19 Dec 2024 16:28:11 +0100 Subject: [PATCH] chore: add script to automatically update the slab github runner --- .../update_slab_github_runner.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 script/actions_utils/update_slab_github_runner.sh diff --git a/script/actions_utils/update_slab_github_runner.sh b/script/actions_utils/update_slab_github_runner.sh new file mode 100755 index 000000000..d94b59418 --- /dev/null +++ b/script/actions_utils/update_slab_github_runner.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This script updates the lab-github-runner in our workflows by replacing the +# lab-github-runner's release commit. +# Note: For security reasons, we prefer updating the commit instead of the tag. + +# Define the release commit to replace +RELEASE_COMMIT="00000000" + +echo "Current directory: $(pwd)" + +# Search for files and process them +for file in $(find .github -type f \( -name "*.yml" -o -name "*.yaml" \)); do + echo "Processing: $file" + + # Extract lines containing "uses: actions/checkout@" with line numbers before modification + echo "Before modifications:" + grep -nE "uses: actions/checkout@" "$file" || echo "No match found" + + # Replace the target line with the new commit, keeping indentation intact + sed -E -i "s|(uses: actions/checkout@)[^[:space:]]*|\1$RELEASE_COMMIT|g" "$file" + + # Extract lines containing "uses: actions/checkout@" after modification + echo "After modifications:" + grep -nE "uses: actions/checkout@" "$file" || echo "No match found" + + echo "Updated: $file" + echo "-------------------------" +done