Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use poetry in workflow #7

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions .github/workflows/pdf-monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,38 @@ jobs:
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: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- 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')
Expand All @@ -36,12 +51,14 @@ jobs:
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"
poetry run python main.py "$pdf_file"
done

- name: Commit and Push Changes
if: ${{ env.pdf_files != '' }}
run: |
Expand All @@ -53,4 +70,4 @@ jobs:
else
git commit -m "Automated commit of changes made by PDF Monitor Workflow"
git push
fi
fi
File renamed without changes.
Loading