0060-01を追加 #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update README and Create PR | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: [closed] | |
branches: | |
- master | |
jobs: | |
update-readme: | |
if: 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: '3.x' | |
- name: Run makeindex.py | |
run: python3 .github/workflows/makeindex.py | |
- name: Check for changes | |
id: check_changes | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
try { | |
const result = await github.rest.repos.compareCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
base: 'master', | |
head: 'update-readme-${{ github.run_number }}' | |
}); | |
if (result.data.files.length > 0) { | |
console.log("Changes detected"); | |
core.setOutput("changes_detected", "true"); | |
} else { | |
console.log("No changes detected"); | |
core.setOutput("changes_detected", "false"); | |
} | |
} catch (error) { | |
if (error.status === 404) { | |
console.log("Branch not found, no changes detected"); | |
core.setOutput("changes_detected", "false"); | |
} else { | |
throw error; | |
} | |
} | |
- name: Commit README.md updates | |
if: steps.check_changes.outputs.changes_detected == 'true' | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git checkout -b update-readme-${{ github.run_number }} | |
git add WAIC-TEST/HTML/README.md | |
git commit -m "Update README.md automatically" | |
git push origin update-readme-${{ github.run_number }} | |
- name: Create Pull Request | |
if: steps.check_changes.outputs.changes_detected == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
branch: update-readme-${{ github.run_number }} | |
commit-message: "Update README.md automatically" | |
title: "Automatically update README.md" | |
body: "This is an auto-generated PR to update README.md file" | |
base: master |