-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from hmasdev/feat-automatically-update-readme
Automatically update README.md with GitHub Actions
- Loading branch information
Showing
7 changed files
with
436 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Automatically update README | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 1 * *" | ||
|
||
env: | ||
BRANCH_HEADER: "bot/update-readme-" | ||
|
||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: pip install -e .[dev] | ||
- name: Run script | ||
run: | | ||
python update_readme.py > README.md | ||
- name: Check if README.md has changed | ||
id: check_changes | ||
run: | | ||
if [[ -n $(git status --porcelain README.md) ]]; then | ||
echo "README.md has changed." | ||
echo "changes_detected=true" >> "$GITHUB_ENV" | ||
else | ||
echo "README.md has not changed." | ||
echo "changes_detected=false" >> "$GITHUB_ENV" | ||
fi | ||
- name: Commit changes | ||
if: env.changes_detected == 'true' | ||
run: | | ||
git checkout -b ${BRANCH_HEADER}${{ github.run_id }} | ||
git config --local user.name "github-actions[bot]" | ||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add README.md | ||
git commit -m "Update README.md" | ||
- name: Push changes | ||
if: env.changes_detected == 'true' | ||
run: git push -u origin ${BRANCH_HEADER}${{ github.run_id }} | ||
- name: Create pull request | ||
if: env.changes_detected == 'true' | ||
run: | | ||
gh pr create \ | ||
--title "Update README.md" \ | ||
--body "This PR updates the README.md file." \ | ||
--base main \ | ||
--head ${BRANCH_HEADER}${{ github.run_id }} \ | ||
--reviewer hmasdev \ | ||
--assignee hmasdev \ | ||
--label "bot" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Oops, something went wrong.