Skip to content

Commit cadd79e

Browse files
authored
Create bot-change.yml
1 parent f9e2c13 commit cadd79e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/bot-change.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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
26+
env:
27+
CHANGE_INSTRUCTION: ${{ github.event.inputs.change }}
28+
run: |
29+
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
34+
python3 scripts/auto_edit.py
35+
git config user.name "github-actions"
36+
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"
39+
git push

0 commit comments

Comments
 (0)