Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
40 lines (34 loc) · 970 Bytes

File metadata and controls

executable file
·
40 lines (34 loc) · 970 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env bash
# This script is used to render GitHub Workflow templates.
set -euo pipefail
# Check the number of arguments. 2 or 3 are expected.
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: render.sh <template> <context> <output>"
exit 1
fi
template="$1"
context="$2"
output="${3:-}"
engine='
s#\$\{\{\{\s*\.?(.*?)\s*\}\}\}#
my $key = $1;
my $result = `jq -cjn '"'"'env.context | fromjson | .$key'"'"'`;
if($? != 0) {
print STDERR "jq: error on line: $_";
exit 1;
}
$result
#gex
'
# Render the template.
export context
# If template and output are the same, perform the rendering in-place.
if [ "$template" = "$output" ]; then
perl -p -i -e "$engine" "$template"
# Otherwise, if output is not specified, print the result to stdout.
elif [ -z "$output" ]; then
perl -p -e "$engine" "$template"
# Otherwise, write the result to the specified output file.
else
perl -p -e "$engine" "$template" > "$output"
fi
Morty Proxy This is a proxified and sanitized view of the page, visit original site.