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