Add Q424 PDF #9
Workflow file for this run
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: PDF Monitor Workflow | |
on: | |
push: | |
paths: | |
- '**/*.pdf' | |
jobs: | |
run-python-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
cache: pip | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Find Changed PDF Files | |
id: find_pdfs | |
run: | | |
if [ $(git rev-parse --is-shallow-repository) = true ]; then | |
# For shallow clones, fetch the full history | |
git fetch --unshallow | |
fi | |
if [ $(git rev-list --count HEAD) -eq 1 ]; then | |
# If only one commit exists, list all PDFs | |
pdf_files=$(git ls-files '*.pdf') | |
else | |
# For subsequent commits, list changed PDFs | |
pdf_files=$(git diff --name-only HEAD^ HEAD | grep '.pdf$') | |
fi | |
echo "pdf_files=$pdf_files" >> $GITHUB_ENV | |
- name: Run Python Script | |
if: env.pdf_files != '' | |
run: | | |
for pdf_file in ${{ env.pdf_files }}; do | |
python main.py "$pdf_file" | |
done | |
- name: Commit and Push Changes | |
if: ${{ env.pdf_files != '' }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
if git diff --cached --quiet; then | |
echo "No changes to commit" | |
else | |
git commit -m "Automated commit of changes made by PDF Monitor Workflow" | |
git push | |
fi |