Merge pull request #4 from simonthorell/setup #4
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: Build PDF | |
on: | |
push: | |
branches: [main] | |
paths: | |
- 'docs/REPORT.md' | |
- 'docs/images/**' | |
- 'protocols/**.md' | |
jobs: | |
# First job: Update REPORT.md | |
update-report: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' # Adjust as needed | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
# Install any dependencies if needed | |
- name: Generate Report | |
run: python scripts/create_report.py | |
- name: Commit and Push Updated Report | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add docs/REPORT.md | |
git commit -m "Update REPORT.md with latest protocols" || echo "No changes to REPORT.md." | |
git push --force | |
# Second job: Convert REPORT.md to PDF | |
converttopdf: | |
name: Markdown to PDF | |
needs: update-report | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Ensures the action can push back to the repository | |
persist-credentials: true | |
fetch-depth: 0 # Fetch all history for .Git based projects | |
# Configure Git | |
- name: Configure Git | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git pull | |
# Remove the old PDFs | |
- name: Remove Outdated PDFs | |
run: | | |
git rm -r pdfs | |
git commit -m "Remove existing pdfs folder" | |
git push --force | |
- uses: baileyjm02/[email protected] | |
with: | |
input_dir: docs | |
output_dir: pdfs | |
images_dir: docs/images | |
image_import: ./images | |
build_html: false | |
# Commit and Push | |
- name: Commit and Push PDF and HTML to main branch | |
run: | | |
git add pdfs/ | |
git status | |
git commit -m "Automated commit of PDF and HTML files" -a || echo "No changes to commit." | |
git push --force |