Skip to content

Commit

Permalink
Update create-pr-if-outdated.yml (#1723)
Browse files Browse the repository at this point in the history
* Update create-pr-if-outdated.yml

* Update README.md
  • Loading branch information
nakamasato authored Nov 4, 2024
1 parent 7acd733 commit fe30cc8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/create-pr-if-outdated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ jobs:
with:
ref: ${{ env.BASE_BRANCH_NAME }}

- name: update date in readme
- name: update readme
run: |
git_last_updated_date=$(git log -1 --format="%at" -- . ":(exclude)README.md" | xargs -I{} date -d @{} +%Y-%m-%d)
python_version=$(cat .python-version)
echo "git_last_updated_date: $git_last_updated_date"
sed -i "s/.*Last Updated: \(.*\)/- Last Updated: $git_last_updated_date/" README.md
sed -i "s/.*Python Version: \(.*\)/- Python Version: $python_version/" README.md
- name: check if need to commit
id: need_commit
Expand All @@ -39,10 +41,10 @@ jobs:
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: update updated_on (github token)'
branch: update-updated-on-github-token
title: 'chore: update updated_on (github token)'
body: 'Update updated_on automatically (github token)'
commit-message: 'chore: update readme (github token)'
branch: update-readme
title: 'chore: update readme (github token)'
body: 'Update readme automatically (github token)'
base: main
delete-branch: true

Expand All @@ -53,11 +55,13 @@ jobs:
with:
ref: ${{ env.BASE_BRANCH_NAME }}

- name: update date in readme
- name: update readme
run: |
git_last_updated_date=$(git log -1 --format="%at" -- . ":(exclude)README.md" | xargs -I{} date -d @{} +%Y-%m-%d)
python_version=$(cat .python-version)
echo "git_last_updated_date: $git_last_updated_date"
sed -i "s/.*Last Updated: \(.*\)/- Last Updated: $git_last_updated_date/" README.md
sed -i "s/.*Python Version: \(.*\)/- Python Version: $python_version/" README.md
- name: check if need to commit
id: need_commit
Expand All @@ -83,9 +87,9 @@ jobs:
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: 'chore: update updated_on (github app)'
branch: update-updated-on-github-app
title: 'chore: update updated_on (github app)'
body: 'Update updated_on automatically (github app)'
commit-message: 'chore: update readme (github app)'
branch: update-readme-github-app
title: 'chore: update readme (github app)'
body: 'Update readme automatically (github app)'
base: main
delete-branch: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# github-actions-practice

- Last Updated: 2024-11-01
- Python Version: 3.12

## Github Actions Table

Expand Down

0 comments on commit fe30cc8

Please sign in to comment.