Advertisements
I want to create on the fly a golang
template file in GitHub Actions.
So I am doing more or less the following:
- name: create the template
shell: bash
run: |
cat <<EOF > myfile.tpl
\{\{- if . \}\}
\{\{- range . \}\}
<h3>Target <code>{{ escapeXML .Target }}</code></h3>
\{\{- if (eq (len .Vulnerabilities) 0) \}\}
<h4>No Vulnerabilities found</h4>
.
.
\{\{- end \}\}
EOF
However, apart from the fact that I get errors when trying to use it, when I cat
it I get the following
\***\***- if . \***\***
\***\***- range . \***\***
<h3>Target <code>*** escapeXML .Target ***</code></h3>
\***\***- if (eq (len .Vulnerabilities) 0) \***\***
<h4>No Vulnerabilities found</h4>
What is the proper way of going about it?
>Solution :
For create agolang
template file in GitHub Actions workflow without the special characters being escaped. Use a different delimiter to the heredoc that prevents interpretation of the special characters. You can achieve this using EOF or another delimiter with quotes. Try the below way, it will be correct.
- name: Create the template
shell: bash
run: |
cat <<'EOF' > myfile.tpl
{{- if . }}
{{- range . }}
<h3>Target <code>{{ escapeXML .Target }}</code></h3>
{{- if (eq (len .Vulnerabilities) 0) }}
<h4>No Vulnerabilities found</h4>
.
.
{{- end }}
{{- end }}
EOF