-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
169 lines (164 loc) · 5.12 KB
/
action.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Copyright (c) Innofactor Plc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause
#
name: Build PDF
author: Innofactor Plc
description: Convert markdown files to a PDF file.
branding:
icon: layout
color: purple
inputs:
FirstChangeDescription:
description: "The first change description."
required: false
type: string
default: Initial draft
Folder:
description: "The repository folder where the order file exist."
required: false
type: string
default: docs
GitLogLimit:
description: "Maximum entries to get from Git Log for version history."
required: false
type: number
default: 15
HistoryFile:
description: "The name of the history file."
required: false
type: string
default: ""
MainAuthor:
description: "The main author of the PDF content."
required: false
type: string
default: "Innofactor"
OrderFile:
description: "The name of the .order file."
required: false
type: string
default: document.order
OutFile:
description: "The name of the output file."
required: false
type: string
default: document.pdf
Project:
description: "The project ID or name."
required: false
type: string
default: ""
SkipGitCommitHistory:
description: "Skip using git commit history."
required: false
type: boolean
default: false
Subtitle:
description: "The document subtitle."
required: false
type: string
default: ""
Template:
description: "The template name. Must be: designdoc."
required: false
type: string
default: designdoc
Title:
description: "The document title."
required: true
type: string
ReplaceFile:
description: "The name of the replace file."
required: false
type: string
default: ""
RetentionDays:
description: "Number of days to retain job artifacts."
required: false
type: number
default: 5
outputs:
pdf:
description: The path to the PDF file.
value: ${{ github.workspace }}/${{ inputs.OutFile }}
runs:
using: composite
steps:
- name: Add tools to system path
shell: sh
run: |
echo "::group::Add tools path"
toolsFolder=$(readlink -f ${GITHUB_ACTION_PATH}/tools)
echo 'Tools folder:'
echo "${toolsFolder}"
echo "${toolsFolder}" >> "${GITHUB_PATH}"
echo 'System path:'
echo "${PATH}"
if test -f "${GITHUB_ACTION_PATH}/tools/requirements.txt"; then
cp -f "${GITHUB_ACTION_PATH}/tools/requirements.txt" ./
fi
echo '::endgroup::'
- name: Cache Tex Live
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
key: ${{ runner.os }}-texlive
path: /opt/texlive
- name: Install requirements
shell: sh
run: |
echo "::group::Install requirements"
install-tools.sh
echo '::endgroup::'
- name: Build PDF
shell: sh
env:
AUTHOR: ${{ inputs.MainAuthor }}
DESCRIPTION: ${{ inputs.FirstChangeDescription }}
TITLE: ${{ inputs.Title }}
SUBTITLE: ${{ inputs.Subtitle }}
FOLDER: ${{ inputs.Folder }}
SKIP_GIT_HISTORY: ${{ inputs.SkipGitCommitHistory }}
HISTORY: ${{ inputs.HistoryFile }}
LIMIT: ${{ inputs.GitLogLimit }}
ORDER_FILE: ${{ inputs.OrderFile }}
OUT_FILE: ${{ inputs.OutFile }}
REPLACE_FILE: ${{ inputs.ReplaceFile }}
PROJECT: ${{ inputs.Project }}
TEMPLATE: ${{ inputs.Template }}
run: |
echo "::group::Build PDF"
git config --global --add safe.directory '*'
convert.sh -a "${AUTHOR}" -d "${DESCRIPTION}" -f "${FOLDER}" \
-force "${SKIP_GIT_HISTORY}" -h "${HISTORY}" -l ${LIMIT} \
-o "${ORDER_FILE}" -out "${OUT_FILE}" -p "${PROJECT}" \
-r "${REPLACE_FILE}" -s "${SUBTITLE}" -t "${TITLE}" \
--template "${TEMPLATE}"
echo '::endgroup::'
- name: Show debug info
if: success() || failure()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1
with:
script: |
const fs = require('fs');
const event = JSON.parse(fs.readFileSync(process.env['GITHUB_EVENT_PATH']));
console.log('::group::environment variables');
console.log('::stop-commands::77e6a57ef9854574');
for (const [key, value] of Object.entries(process.env).sort()) {
if (key != 'INPUT_SCRIPT') {
console.log(`${key}=${value}`);
}
}
console.log('::77e6a57ef9854574::');
console.log('::endgroup::');
console.log('::group::github event');
console.log('::stop-commands::77e6a57ef9854574');
console.log(JSON.stringify(event, null, 2));
console.log('::77e6a57ef9854574::');
console.log('::endgroup::');
- name: Publish PDF
uses: actions/upload-artifact@ef09cdac3e2d3e60d8ccadda691f4f1cec5035cb #v4.3.1 + 3 commits
with:
if-no-files-found: error
name: ${{ inputs.OutFile }}
retention-days: ${{ inputs.RetentionDays }}
path: ${{ github.workspace }}/${{ inputs.OutFile }}*