Skip to content

Commit 0a5c01b

Browse files
committed
Export PDF workflow.
1 parent e1aa83a commit 0a5c01b

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Export Keynote to PDF
2+
3+
on:
4+
push:
5+
paths:
6+
- "**/*.key"
7+
- ".github/workflows/export-keynote.yml"
8+
workflow_dispatch:
9+
inputs:
10+
keynote_glob:
11+
description: 'Glob for .key files (default **/*.key)'
12+
required: false
13+
default: '**/*.key'
14+
15+
jobs:
16+
export:
17+
runs-on: [self-hosted, macOS]
18+
environment: export-keynote
19+
20+
env:
21+
# You can override this at dispatch time with the input above
22+
KEYNOTE_GLOB: ${{ github.event.inputs.keynote_glob || '**/*.key' }}
23+
OUT_DIR: out-pdf
24+
25+
steps:
26+
- name: Check out
27+
uses: actions/checkout@v4
28+
29+
- name: Verify Keynote is installed
30+
shell: bash
31+
run: |
32+
if ! osascript -e 'id of app "Keynote"' >/dev/null 2>&1; then
33+
echo "Keynote.app not found on this runner. Install from the Mac App Store."
34+
exit 1
35+
fi
36+
37+
- name: Prepare output directory
38+
shell: bash
39+
run: |
40+
rm -rf "$OUT_DIR"
41+
mkdir -p "$OUT_DIR"
42+
43+
- name: Find Keynote files
44+
id: find_keys
45+
shell: bash
46+
run: |
47+
# Fall back to simple find since bash 3.2 is ancient on macOS
48+
files=$(find . -type f -name "*.key")
49+
if [ -z "$files" ]; then
50+
echo "No .key files found."
51+
exit 1
52+
fi
53+
echo "Found Keynote files:"
54+
echo "$files"
55+
# Save list for next step
56+
printf "%s\n" $files > keynote_files.txt
57+
58+
- name: Export all Keynote files to PDF
59+
shell: bash
60+
run: |
61+
APPLESCRIPT='
62+
on run argv
63+
set srcPosix to item 1 of argv
64+
set dstPosix to item 2 of argv
65+
set srcAlias to POSIX file srcPosix as alias
66+
tell application "Keynote"
67+
activate
68+
set theDoc to open srcAlias
69+
try
70+
export theDoc to (POSIX file dstPosix) as PDF
71+
on error errMsg number errNum
72+
try
73+
close theDoc saving no
74+
end try
75+
error errMsg number errNum
76+
end try
77+
close theDoc saving no
78+
end tell
79+
end run
80+
'
81+
while read keyfile; do
82+
[ -z "$keyfile" ] && continue
83+
base="$(basename "${keyfile%.key}")"
84+
out="$OUT_DIR/$base.pdf"
85+
echo "Exporting: $keyfile -> $out"
86+
mkdir -p "$(dirname "$out")"
87+
osascript -e "$APPLESCRIPT" "$PWD/$keyfile" "$PWD/$out"
88+
done < keynote_files.txt
89+
90+
- name: Upload PDFs
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: Keynote-PDFs
94+
path: ${{ env.OUT_DIR }}/*.pdf
95+
if-no-files-found: error

0 commit comments

Comments
 (0)