-
Notifications
You must be signed in to change notification settings - Fork 3
143 lines (136 loc) · 5.53 KB
/
render.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Reusable workflow to render the spec for a variety of purposes.
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
name: render
on:
workflow_call:
inputs:
container:
description: the Docker container to use (default is trustedcomputinggroup/pandoc)
required: false
type: string
default: ghcr.io/trustedcomputinggroup/pandoc
container-version:
description: the released version of the Docker container to use
required: true
type: string
input:
description: the Markdown file to render
required: true
type: string
workflow:
description: the workflow to run ('pr', 'push', 'release', 'manual')
required: true
type: string
manual_diffbase:
description: diffbase for manual workflow
required: false
type: string
revision:
description: version to render (defaults is default branch)
required: false
type: string
jobs:
render:
runs-on: ubuntu-latest
container:
image: ${{ inputs.container }}:${{ inputs.container-version }}
name: Render
steps:
# Use the input file name (no extension) as the base filename for the output
- name: Calculate output file name
id: gen_output_name
run: |
filename=$(basename ${{ inputs.input }})
filename="${filename%.*}"
echo OUTPUT_FILENAME="${filename}" >> "$GITHUB_OUTPUT"
echo output filename: ${filename}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.revision }}
fetch-depth: 0
fetch-tags: true
# Cache the LaTeX files. Use input file and container version in the cache
# key so that the cache is invalidated upon file change or container
# version change.
- name: Cache LaTeX files
uses: actions/cache@v4
env:
cache-name: cache-latex-${{ inputs.input }}-files
with:
path: |
*.aux
*.fdb_latexmk
*.lof
*.lot
*.toc
*.upa
*.upb
*.convert.pdf
*.mermaid.pdf
key: latex-${{ inputs.input }}-${{ inputs.container-version }}-${{ github.run_id }}
restore-keys: latex-${{ inputs.input }}-${{ inputs.container-version }}
# Note: It appears that we can't pass variables into 'uses:' below to allow callers to
# request a version of the action. Referencing it by local path breaks external workflows
# that call to this one.
# The unfortunate workaround is for this file to be updated to point at specific commits
# and reference that version of the action file in this reusable workflow.
# Note: It appears that we can't pass variables into 'uses:' below to allow callers to
# request a version of the action. Referencing it by local path breaks external workflows
# that call to this one.
# The unfortunate workaround is for this file to be updated to point at specific commits
# and reference that version of the action file in this reusable workflow.
# Render the document with diffs in the 'pr' mode.
- name: Render
if: inputs.workflow == 'pr'
uses: trustedcomputinggroup/pandoc/.github/actions/render@8f79b567c9dc6b15afba5d83d61e0d37f9508c47
with:
input-md: ${{ inputs.input }}
output-basename: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}
pdf: true
diffbase: "${{ github.event.pull_request.base.sha }}"
pr-number: "${{ github.event.number }}"
pr-repo: "${{ github.repository }}"
# Render the document with diffs in the 'manual' mode.
- name: Render
if: inputs.workflow == 'manual'
uses: trustedcomputinggroup/pandoc/.github/actions/render@8f79b567c9dc6b15afba5d83d61e0d37f9508c47
with:
input-md: ${{ inputs.input }}
output-basename: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}
pdf: true
diffbase: "${{ inputs.manual_diffbase }}"
# Render the document without diffs in other modes.
- name: Render
if: inputs.workflow != 'pr' && inputs.workflow != 'manual'
uses: trustedcomputinggroup/pandoc/.github/actions/render@8f79b567c9dc6b15afba5d83d61e0d37f9508c47
with:
input-md: ${{ inputs.input }}
output-basename: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}
pdf: true
# Upload the PDF to the release in 'release' mode
- name: Upload to release
if: inputs.workflow == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.*.pdf
tag: ${{ github.ref }}
asset_name: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.pdf
overwrite: true
file_glob: true
# Always upload all PDF and log files to the workflow artifacts
- name: Upload pdfs
uses: actions/upload-artifact@v4
with:
name: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.pdf
path: |
${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.*.pdf
if: always()
- name: Upload logs
uses: actions/upload-artifact@v4
with:
name: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.log
path: |
${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.*.log
if: always()