Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
seikhchilli committed May 3, 2024
1 parent f7e5c52 commit 6e3ff3a
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/UpdateReadmeOnPush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,38 @@ jobs:
with:
python-version: '3.12'

- name: Check if files match naming pattern
id: check-files
- name: Check for Allowed File Changes
uses: tj-actions/verify-changed-files@v19
id: verify-changes
with:
# Only check for changes in Python and C++ files
files: |
**/*.py
**/*.cpp
# Fail if no allowed files changed
fail_on_empty_changes: true

- name: Check File Names
run: |
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
files=$(git diff --name-only HEAD~1 HEAD -- ./ | grep -E '^\d+[A-Z]\.(cpp|py)$' | grep -v '^\.github/')
if [[ ! -z "$files" ]]; then
echo "::set-env name=CHANGED::true"
echo "::set-env name=UPDATED_FILES::$files"
else
echo "::set-env name=CHANGED::false"
changed_files=${{ steps.verify-changes.outputs.changed_files }}
for file in $changed_files; do
if [[ ! ($file =~ ^\d[A-Z]\.(cpp|py)$ ]]; then
echo "Error: File '$file' does not match allowed pattern"
exit 1
fi
else
echo "::warning:: No previous commit found. Skipping checks."
fi
done
- name: Run Python script to update README
if: env.CHANGED == 'true'
run: python update_readme.py ${{ env.UPDATED_FILES }}
run: python update_readme.py ${{ steps.verify-changes.outputs.changed_files }}

- name: Commit changes
if: env.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: env.CHANGED == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.CODEFORCES_GITHUB_TOKEN }}

0 comments on commit 6e3ff3a

Please sign in to comment.