Skip to content

Commit

Permalink
build: add replace scripts and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
charleslavon committed Jun 28, 2024
1 parent 9e79fb1 commit 2248e91
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/fix_paths.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
push:
branches: [develop]
permissions:
contents: write

jobs:
fix-paths:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: script
shell: bash
run: ./bin/replace_all.sh

- name: Check the diff
id: check_diff
run: |
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
- name: Log next steps
if: steps.check_diff.outputs.changed != 'true'
run: |
echo "Workflow detected that no changes are needed."
- name: create pull request
if: steps.check_diff.outputs.changed == 'true'
run: gh pr create -B base_branch -H branch_to_merge -m 'auto-update URL paths in response to marketing content update'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions bin/search_and_replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ echo "Searching for '$search_string' and replacing with '$replacement_string' in
# Use find command to search for files recursively in the directory
find "$directory" -type f -print0 | while IFS= read -r -d '' file; do
# Perform the search and replace using sed
#sed -i 's/'$search_string'/'$replacement_string'/g' "$file"
sed -i 's/'$search_string'/'$replacement_string'/g' "$file"
# Note: the above sed command works on unix/linux, but not on MacOS
# To run this script locally on a mac, comment out the above and use the line below
sed -i '' 's/'$search_string'/'$replacement_string'/g' "$file"
# sed -i '' 's/'$search_string'/'$replacement_string'/g' "$file"
echo "Modified: $file"
done

Expand Down

0 comments on commit 2248e91

Please sign in to comment.