Skip to content

Merge pull request #252 from waic/add-test-0091-01 #47

Merge pull request #252 from waic/add-test-0091-01

Merge pull request #252 from waic/add-test-0091-01 #47

Workflow file for this run

name: Update README and Create PR
# 環境変数の定義
env:
README_PATH: WAIC-TEST/HTML/README.md
PYTHON_VERSION: '3.11'
SCRIPT_PATH: .github/workflows/makeindex.py
BOT_NAME: "GitHub Actions Bot"
BRANCH_PREFIX: update-readme
on:
push:
branches:
- master
pull_request:
types: [closed]
branches:
- master
permissions:
contents: write
pull-requests: write
jobs:
update-readme:
# ジョブを実行する条件:
# 1. master ブランチへの直接プッシュ
# 2. master ブランチにマージされたプルリクエストのクローズ
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: master
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
# makeindex.py 実行とエラーハンドリング
- name: Run makeindex.py
run: |
if ! python3 ${{ env.SCRIPT_PATH }}; then
echo "Error: makeindex.py failed"
exit 1
fi
# README.md の変更のみを確認
- name: Check for changes
id: check_changes
run: |
if git diff --quiet ${{ env.README_PATH }}; then
echo "No changes detected in README.md"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in README.md"
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi
# PRの作成
- name: Create Pull Request
if: steps.check_changes.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v7
with:
commit-message: "Update README.md automatically [skip ci]"
title: "🤖 README.md の自動更新"
body: |
### 自動更新の内容
- ${{ env.README_PATH }} ファイルの内容を最新の状態に更新
> このPRは GitHub Actions により自動生成されています。
> 生成日時: ${{ github.event.head_commit.timestamp }}
branch: ${{ env.BRANCH_PREFIX }}-${{ github.run_number }}
base: master
add-paths: |
${{ env.README_PATH }}
delete-branch: true
token: ${{ secrets.GITHUB_TOKEN }}