Skip to content

Commit

Permalink
Make README regen only commit when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
SKPG-Tech committed Sep 30, 2023
1 parent 07d9857 commit 749d15b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/readme_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
import os

path = sys.argv[1]

os.chdir(path)
diff = os.popen('git diff').readlines()

if not diff[10].startswith('+> Report generated on') and not diff[8].startswith('-> Report generated on'):
print('true')
else:
print('false')
4 changes: 4 additions & 0 deletions .github/workflows/readme_regen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ jobs:
- name: Generate new README.md
run: python ${{ github.workspace }}/generate_readme.py

- name: Check if commit is needed
run: echo "COMMIT_NEEDED=$(python ${{ github.workspace }}/.github/workflows/readme_check.py ${{ github.workspace }})" >> $GITHUB_ENV

- name: Commit changes
if: ${{ env.COMMIT_NEEDED == 'true' }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ the feasibility.
* πŸ‡·πŸ‡Ί [Russian](/translations/rus.po) (100% complete! πŸŽ‰)
* πŸ‡¬πŸ‡ͺ [Georgian](/translations/kat.po) (100% complete! πŸŽ‰)
* πŸ’» [Code](/translations/code.po) (100% complete! πŸŽ‰)
> Report generated on Sep 30 2023 14:19:30 UTC
> Report generated on Sep 30 2023 19:15:58 UTC
2 changes: 1 addition & 1 deletion generate_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

# Write the README
readme_file = "README.md"
with open(readme_file, 'w', encoding="utf8", newline='\n') as f:
with open(readme_file, 'w', encoding="utf8", newline='\r\n') as f:
f.write(header)

results = []
Expand Down

0 comments on commit 749d15b

Please sign in to comment.