Skip to content

Commit

Permalink
add new acrion to generate pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbcbauer authored Jul 10, 2024
1 parent e49980b commit 0613842
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/reusiable-pdf-generator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'Convert Markdown to PDF'
description: 'A GitHub Action to convert Markdown files to PDF and push to a specific branch'
inputs:
folder:
description: 'Path to the folder containing Markdown files'
required: true
default: 'meetings'
outputs: {}
runs:
using: 'composite'
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Pandoc
run: sudo apt-get install pandoc -y

- name: Install Dependencies
run: |
pip install pypandoc
pip install pyyaml
- name: Convert Markdown to PDF
run: |
mkdir -p output
for file in ${{ inputs.folder }}/*.md; do
filename=$(basename "$file" .md)
pandoc "$file" -o "output/$filename.pdf"
done
- name: Check if pdf-branch exists
id: check-branch
run: |
if git ls-remote --heads origin pdf-branch; then
echo "::set-output name=branch_exists::true"
else
echo "::set-output name=branch_exists::false"
fi
- name: Create pdf-branch if it does not exist
if: steps.check-branch.outputs.branch_exists == 'false'
run: |
git checkout -b pdf-branch
git push --set-upstream origin pdf-branch
- name: Commit and Push PDFs
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if [ "$(git branch --list pdf-branch)" ]; then
git checkout pdf-branch
else
git checkout -b pdf-branch
fi
cp -r output/* .
git add *.pdf
DATE=$(date +'%Y-%m-%d')
git commit -m "Add converted PDF files on $DATE"
git push --force --set-upstream origin pdf-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 0613842

Please sign in to comment.