Skip to content

Commit

Permalink
fix(chore): run platform specific sed
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Apr 29, 2024
1 parent 6466819 commit 8f889e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/auto-check-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ jobs:
run: |
echo "* available branches:"
git branch | cat
echo "default branch: '${{ github.event.repository.default_branch }}'"
echo "========"
git checkout main
git pull origin main
git add .
git commit -m "chore(gh-actions): apply auto-check edits"
git push -u origin main
git push -u origin ${{ github.event.repository.default_branch }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 23 additions & 18 deletions scripts/automate-checklist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,29 @@ function update-all-generic() {
# - release-workflow.yml
find "$folder" -name "$name" -type f -print0 | while IFS= read -r -d '' file; do
echo "Processing file: $file"
if ! sed -i "s/${target}/${replacement}/g" "$file"; then
# sed help:
# '': no file backup needed (we modify the file in place without backing up original)
# but not that this is only required for mac. for linux, you dont need the '' not
# in the code as we run in linux, but if we wanted it to work on mac it would be:
# if ! sed -i '' ...
#
# -i: The in-place edit flag, which tells sed to modify the original file inline.
# 's/search_pattern/replacement_text/g':
#
# s: Indicates that this is a substitution command.
# /search_pattern/: The pattern to search for.
# /replacement_text/: The text to replace the search pattern with.
# g: The global flag, which ensures that all occurrences of the
# search pattern are replaced, not just the first one.

echo "!!! ⛔ Sed failed for $file"
return 1
uname_output=$(uname)
# sed help:
# '': no file backup needed (we modify the file in place without backing up original)
# but note that this is only required for mac. for linux, you dont need the ''.
#
# -i: The in-place edit flag, which tells sed to modify the original file inline.
# 's/search_pattern/replacement_text/g':
#
# s: Indicates that this is a substitution command.
# /search_pattern/: The pattern to search for.
# /replacement_text/: The text to replace the search pattern with.
# g: The global flag, which ensures that all occurrences of the
# search pattern are replaced, not just the first one.
if [[ "$uname_output" == *"Darwin"* ]]; then
if ! sed -i '' "s/${target}/${replacement}/g" "$file"; then
echo "!!! ⛔ Sed on mac failed for $file"
return 1
fi
else
if ! sed -i "s/${target}/${replacement}/g" "$file"; then
echo "!!! ⛔ Sed on linux failed for $file"
return 1
fi
fi
done

Expand Down

0 comments on commit 8f889e8

Please sign in to comment.