Formatting... #11
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: | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize, reopened, labeled, unlabeled] | |
paths: | |
- 'docs/REPORT.md' | |
- 'docs/REPORT.stub' | |
- 'docs/images/**' | |
- 'protocols/**.md' | |
- '.github/workflows/convert-to-pdf.yml' | |
jobs: | |
merge-markdown-files: # First job: Merge markdown files | |
name: Merge Markdown Files | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print Branch Names (for debugging purposes) | |
run: | | |
echo "The baseref is $GITHUB_BASE_REF" | |
echo "The headref is $GITHUB_HEAD_REF" | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 'pypy3.9' # Set to latest possible | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
# Install any dependencies if needed | |
- name: Checkout PR Head Branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
fetch-depth: 0 # Fetch all history for .Git based projects | |
- name: Generate Report | |
run: python ./scripts/create_report.py # For 'on' try without './' if it doesn't work | |
- name: Set up Git and Commit Changes | |
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 origin ${{ github.head_ref }} | |
convert-to-pdf: # Second job: Convert REPORT.md to PDF | |
name: Convert to PDF | |
needs: merge-markdown-files | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: true # Ensures the action can push back to the repository | |
fetch-depth: 0 # Fetch all history for .Git based projects | |
- name: Checkout to Git Feature Branch | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git fetch origin ${{ github.head_ref }} | |
git checkout ${{ github.head_ref }} | |
- name: Remove Outdated PDFs | |
run: | | |
if [ -d "./pdfs" ]; then | |
git rm -r ./pdfs | |
git commit -m "Remove existing pdfs folder" | |
git push origin ${{ github.head_ref }} | |
else | |
echo "pdfs folder does not exist, skipping removal." | |
fi | |
- uses: baileyjm02/[email protected] | |
with: | |
input_dir: docs | |
output_dir: pdfs | |
images_dir: docs/images | |
image_import: ./images | |
build_html: false # Set true to also add HTML files to the output directory | |
- name: Commit and Push PDF to Main | |
run: | | |
git add pdfs/ | |
git commit -m "Automated PDF Creation" -a || echo "No changes to commit." | |
git push origin ${{ github.head_ref }} |