Skip to content

Commit ca69d13

Browse files
authored
Update bot-change.yml
1 parent cadd79e commit ca69d13

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

.github/workflows/bot-change.yml

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
1-
name: Bot change from input
2-
on:
3-
workflow_dispatch:
4-
inputs:
5-
change:
6-
description: 'Short instruction for the bot'
7-
required: true
8-
9-
permissions:
10-
contents: write
11-
12-
jobs:
13-
run-bot:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 0
19-
20-
- name: Set up Python
21-
uses: actions/setup-python@v4
22-
with:
23-
python-version: '3.11'
24-
25-
- name: Run bot script
1+
- name: Run copy-edit bot
262
env:
273
CHANGE_INSTRUCTION: ${{ github.event.inputs.change }}
284
run: |
295
mkdir -p scripts
30-
echo 'import os, pathlib' > scripts/auto_edit.py
31-
echo 'instr = os.environ.get("CHANGE_INSTRUCTION","(no instruction)")' >> scripts/auto_edit.py
32-
echo 'p = pathlib.Path("BOT_CHANGES.md")' >> scripts/auto_edit.py
33-
echo 'p.write_text(p.read_text() + f"- {instr}\n" if p.exists() else f"- {instr}\n")' >> scripts/auto_edit.py
6+
cat <<'PY' > scripts/auto_edit.py
7+
import pathlib
8+
search_text = "Add React to an Existing Project"
9+
replace_text = "Add React to your Existing Project"
10+
11+
# loop through all .md files in the repo
12+
for md_file in pathlib.Path('.').rglob('*.md'):
13+
content = md_file.read_text()
14+
if search_text in content:
15+
md_file.write_text(content.replace(search_text, replace_text))
16+
print(f"Updated {md_file}")
17+
PY
3418
python3 scripts/auto_edit.py
3519
git config user.name "github-actions"
3620
git config user.email "[email protected]"
37-
git add BOT_CHANGES.md
38-
git commit -m "bot: apply change ${{ github.event.inputs.change }}" || echo "No changes to commit"
21+
git add .
22+
git commit -m "bot: apply copy edit" || echo "No changes to commit"
3923
git push

0 commit comments

Comments
 (0)