update readme #5
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 on Push or Pull Request | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.12' | |
- name: Check if files match naming pattern | |
id: check-files | |
run: | | |
if git diff --name-only HEAD~1 HEAD -- ./ | grep -E '^\d+[A-Z]\.(cpp|py)$' | grep -v '^\.github/'; then | |
echo "::set-output name=changed::true" | |
echo "::set-output name=updated_files::$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E '^\d+[A-Z]\.(cpp|py)$')" | |
else | |
echo "::set-output name=changed::false" | |
fi | |
- name: Run Python script to update README | |
if: steps.check-files.outputs.changed == 'true' | |
run: python update_readme.py ${{ steps.check-files.outputs.updated_files }} | |
- name: Commit changes | |
if: steps.check-files.outputs.changed == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
git add README.md | |
git commit -m "Update README" | |
- name: Push changes | |
if: steps.check-files.outputs.changed == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.CODEFORCES_GITHUB_TOKEN }} |