-
Notifications
You must be signed in to change notification settings - Fork 2
fix: remove yq install step and move sh script to separate file [DX-2072] #1295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00a7b02
fix: remove yq install step and move sh script to separate file
ecPablo c0019fb
fix: sh path
ecPablo 25f2611
Potential fix for code scanning alert no. 687: Code injection
ecPablo 9eb246b
fix: permissions
ecPablo 9a5c201
Update actions/bump-mcms-tools/scripts/update-workflow-files.sh
ecPablo 4c27a75
chore: changeset
ecPablo dc9c02c
Update actions/bump-mcms-tools/action.yml
ecPablo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"bump-mcms-tools": minor | ||
--- | ||
|
||
add bump mcms tools composite action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
IFS=$'\n\t' | ||
|
||
changed=false | ||
|
||
echo "::notice::Searching for steps using pattern: $PATTERN" | ||
echo "::notice::Latest version to set: $LATEST" | ||
echo "::notice::Workflows regex: $WORKFLOWS_REGEX" | ||
|
||
# Find workflow files | ||
mapfile -d '' files < <(find . -regextype posix-extended -regex "$WORKFLOWS_REGEX" -type f -print0 || true) | ||
total=${#files[@]} | ||
echo "::notice::Found $total potential workflow file(s)" | ||
if [[ $total -eq 0 ]]; then | ||
echo "::warning::No workflow files matched regex ($WORKFLOWS_REGEX)" | ||
echo "changed=$changed" | tee -a "$GITHUB_OUTPUT" | ||
exit 0 | ||
fi | ||
|
||
for f in "${files[@]}"; do | ||
echo "::group::Processing $f" | ||
|
||
# Count steps that use the action | ||
match_count=$(yq -r ' | ||
[ | ||
.jobs[]?.steps[]? | ||
| select((.uses // "") | type == "!!str" and (.uses | test("^'"$PATTERN"'"))) | ||
] | length | ||
' "$f") | ||
|
||
if [[ "$match_count" -eq 0 ]]; then | ||
echo "::notice::No steps using the action — skipping." | ||
echo "::endgroup::" | ||
continue | ||
fi | ||
|
||
# Count how many of those are NOT already at the latest version (missing or different) | ||
diff_count=$(yq -r ' | ||
[ | ||
.jobs[]?.steps[]? | ||
| select((.uses // "") | type == "!!str" and (.uses | test("^'"$PATTERN"'"))) | ||
| (.with.version // "") | select(. != "'"$LATEST"'") | ||
] | length | ||
' "$f") | ||
|
||
# For visibility, list current distinct versions on matched steps | ||
echo "::notice::Matched steps: $match_count" | ||
echo "::notice::Current versions on matched steps:" | ||
yq -r ' | ||
.jobs[]?.steps[]? | ||
| select((.uses // "") | type == "!!str" and (.uses | test("^'"$PATTERN"'"))) | ||
| (.with.version // "<missing>") | ||
' "$f" | sed 's/^/ - /' | ||
|
||
if [[ "$diff_count" -eq 0 ]]; then | ||
echo "::notice::↩️ All matched steps already at $LATEST — no update needed." | ||
echo "::endgroup::" | ||
continue | ||
fi | ||
|
||
before_hash=$(sha1sum "$f" | cut -d' ' -f1) | ||
|
||
# Patch ONLY matched steps | ||
yq -i ' | ||
(.jobs[]?.steps[]? | ||
| select((.uses // "") | type == "!!str" and (.uses | test("^'"$PATTERN"'"))) | ||
| .with.version) = "'"$LATEST"'" | ||
' "$f" | ||
|
||
after_hash=$(sha1sum "$f" | cut -d' ' -f1) | ||
|
||
if [[ "$before_hash" != "$after_hash" ]]; then | ||
echo "::notice::✅ Updated $f → version set to $LATEST" | ||
changed=true | ||
else | ||
echo "::notice::↩️ No change detected after patch (already up-to-date/normalized)." | ||
fi | ||
|
||
echo "::endgroup::" | ||
done | ||
|
||
if [[ "$changed" == "true" ]]; then | ||
echo "::notice::Workflow(s) updated to $LATEST" | ||
else | ||
echo "::notice::All relevant workflows already at latest version ($LATEST)" | ||
fi | ||
|
||
echo "changed=$changed" | tee -a "$GITHUB_OUTPUT" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.