-
Notifications
You must be signed in to change notification settings - Fork 10
69 lines (63 loc) · 2.34 KB
/
markdownToPDF.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Converting outbound checklists from .md to .pdf
on:
pull_request:
types: [opened, synchronize]
# Paths can be used to only trigger actions when you have edited checklist files or assets directory
paths:
- 'tier*/checklist.md'
- 'assets/**'
jobs:
get-updated-files:
name: Get changed directories
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Get changed directories
id: get-dirs
run: |
# Get the list of changed tier directories
git diff --name-only HEAD~1 | awk -F "/*[^/]*/*$" '{ print ($1 == "" ? "." : $1); }' | sort | uniq | grep '^tier' > changed_dirs.txt
# Read the contents into an array called dirs
readarray -t dirs < changed_dirs.txt
# Print the array for debugging
echo "Changed tier directories:"
for dir in "${dirs[@]}"; do
echo "$dir"
done
# Set the array as a comma-separated string in an output variable
dirs_string=$(IFS=','; echo "${dirs[*]}")
echo "tiers=$dirs_string" >> $GITHUB_ENV # Set the environment variable
outputs:
tiers: ${{ steps.get-dirs.outputs.tiers }}
converttopdf:
name: Build PDF
runs-on: ubuntu-latest
needs: get-updated-files
permissions:
contents: write # Set permissions to allow writes to the repository
strategy:
matrix:
tier: ${{ needs.get-updated-files.outputs.tiers }} # List of directories
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Generate PDF for ${{ matrix.tier }}
uses: baileyjm02/markdown-to-pdf@v1
with:
input_path: ${{ matrix.tier }}/checklist.md
images_dir: assets
image_import: ../assets
output_dir: ${{ matrix.tier }}/
# Default is true, can set to false to only get PDF files
build_html: false
- name: Commit and push ${{ matrix.tier }} PDF
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Updated ${{ matrix.tier }} checklist pdf"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for authentication