Add Date to Report #30
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 | |
- 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 }} | |
generate-diagrams: | |
name: Generate Diagrams | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 'pypy3.9' # Adjust Python version as necessary | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install matplotlib | |
- 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: 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 Diagrams | |
run: | | |
if [ -d "./images" ]; then | |
git rm -r ./images/protocols_datarate.png | |
git rm -r ./images/protocols_frequency.png | |
git rm -r ./images/protocols_range.png | |
git commit -m "Remove existing pdfs folder" | |
git push origin ${{ github.head_ref }} | |
else | |
echo "images folder does not exist, skipping removal." | |
fi | |
- name: Generate Diagrams | |
run: | | |
if [ ! -d "./images" ]; then | |
mkdir images | |
else | |
echo "images folder already exists, skipping creation." | |
fi | |
python ./scripts/create_diagram.py | |
- name: Set up Git and Commit Changes | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add images/ | |
git commit -m "Created diagrams and saved to images-folder" || echo "No diagrams to create" | |
git push origin ${{ github.head_ref }} | |
convert-to-pdf: # Second job: Convert REPORT.md to PDF | |
name: Convert to PDF | |
needs: [merge-markdown-files, generate-diagrams] | |
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: 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 }} |