1
1
name : Update README and Create PR
2
2
3
+ # 環境変数の定義
4
+ env :
5
+ README_PATH : WAIC-TEST/HTML/README.md
6
+ PYTHON_VERSION : ' 3.11'
7
+ SCRIPT_PATH : .github/workflows/makeindex.py
8
+ BOT_NAME : " GitHub Actions Bot"
9
+ BRANCH_PREFIX : update-readme
10
+
3
11
on :
4
12
push :
5
13
branches :
9
17
branches :
10
18
- master
11
19
20
+ permissions :
21
+ contents : write
22
+ pull-requests : write
23
+
12
24
jobs :
13
25
update-readme :
14
26
# ジョブを実行する条件:
@@ -27,38 +39,44 @@ jobs:
27
39
- name : Set up Python
28
40
uses : actions/setup-python@v5
29
41
with :
30
- python-version : ' 3.x '
42
+ python-version : ${{ env.PYTHON_VERSION }}
31
43
44
+ # makeindex.py 実行とエラーハンドリング
32
45
- name : Run makeindex.py
33
- run : python3 .github/workflows/makeindex.py
46
+ run : |
47
+ if ! python3 ${{ env.SCRIPT_PATH }}; then
48
+ echo "Error: makeindex.py failed"
49
+ exit 1
50
+ fi
34
51
52
+ # README.md の変更のみを確認
35
53
- name : Check for changes
36
54
id : check_changes
37
55
run : |
38
- if git diff --quiet; then
39
- echo "No changes detected"
56
+ if git diff --quiet ${{ env.README_PATH }} ; then
57
+ echo "No changes detected in README.md "
40
58
echo "changes_detected=false" >> $GITHUB_OUTPUT
41
59
else
42
- echo "Changes detected"
60
+ echo "Changes detected in README.md "
43
61
echo "changes_detected=true" >> $GITHUB_OUTPUT
44
62
fi
45
63
46
- - name : Commit README.md updates
47
- if : steps.check_changes.outputs.changes_detected == 'true'
48
- run : |
49
- git config --global user.email "action@github.com"
50
- git config --global user.name "GitHub Action"
51
- git checkout -b update-readme-${{ github.run_number }}
52
- git add WAIC-TEST/HTML/README.md
53
- git commit -m "Update README.md automatically"
54
- git push origin update-readme-${{ github.run_number }}
55
-
64
+ # PRの作成
56
65
- name : Create Pull Request
57
66
if : steps.check_changes.outputs.changes_detected == 'true'
58
67
uses : peter-evans/create-pull-request@v7
59
68
with :
60
- branch : update-readme-${{ github.run_number }}
61
- commit-message : " Update README.md automatically"
62
- title : " Automatically update README.md"
63
- body : " This is an auto-generated PR to update README.md file"
69
+ commit-message : " Update README.md automatically [skip ci]"
70
+ title : " 🤖 README.md の自動更新"
71
+ body : |
72
+ ### 自動更新の内容
73
+ - ${{ env.README_PATH }} ファイルの内容を最新の状態に更新
74
+
75
+ > このPRは GitHub Actions により自動生成されています。
76
+ > 生成日時: ${{ github.event.head_commit.timestamp }}
77
+ branch : ${{ env.BRANCH_PREFIX }}-${{ github.run_number }}
64
78
base : master
79
+ add-paths : |
80
+ ${{ env.README_PATH }}
81
+ delete-branch : true
82
+ token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments