From c7daab9f853b01eb0891a30da1f90c33cb727e01 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Mon, 29 Apr 2024 11:02:54 +0100 Subject: [PATCH] fix(chore): run platform specific sed --- .github/workflows/auto-check-workflow.yml | 5 ++- scripts/automate-checklist.sh | 41 +++++++++++++---------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/auto-check-workflow.yml b/.github/workflows/auto-check-workflow.yml index 4971832..c57d69f 100644 --- a/.github/workflows/auto-check-workflow.yml +++ b/.github/workflows/auto-check-workflow.yml @@ -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 }} diff --git a/scripts/automate-checklist.sh b/scripts/automate-checklist.sh index 9b9bfd9..c60f2c7 100644 --- a/scripts/automate-checklist.sh +++ b/scripts/automate-checklist.sh @@ -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