Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
- arm
goarm:
- "7"
ignore:
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
flags:
- -mod=vendor
ldflags:
- -w -s

archives:
- formats: [binary]
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![StepSecurity Maintained Action](https://raw.githubusercontent.com/step-security/maintained-actions-assets/main/assets/maintained-action-banner.png)](https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions)

# Render Template

[![main](https://github.com/step-security/render-template/actions/workflows/main.yml/badge.svg)](https://github.com/step-security/render-template/actions/workflows/main.yml)
[![main](https://github.com/chuhlomin/render-template/actions/workflows/main.yml/badge.svg)](https://github.com/chuhlomin/render-template/actions/workflows/main.yml)
[![release](https://github.com/chuhlomin/render-template/actions/workflows/release.yml/badge.svg)](https://github.com/chuhlomin/render-template/actions/workflows/release.yml)
[![DockerHub](https://img.shields.io/badge/docker-hub-4988CC)](https://hub.docker.com/repository/docker/chuhlomin/render-template)

GitHub Action to render file based on template and passed variables.

Expand Down Expand Up @@ -94,13 +94,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v3

<...>

- name: Render template
id: render_template
uses: step-security/render-template@v1
uses: chuhlomin/render-template@v1
with:
template: kube.template.yml
vars: |
Expand Down
5 changes: 2 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Render Template
description: Renders file based on template and passed variables

author: step-security
author: Konstantin Chukhlomin <mail@chuhlomin.com>

branding:
icon: file-text
Expand Down Expand Up @@ -33,6 +33,5 @@ outputs:
description: Rendered file content

runs:
using: 'docker'
using: docker
image: 'docker://ghcr.io/step-security/render-template:v1.10.0@sha256:9c1fc91677928a9f3a4fe0a8eb1a218ca40be178e7c5a4871d754022a54b4c59' #v1.10.0

89 changes: 89 additions & 0 deletions binary/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Render Template (binary)
description: Renders file based on template and passed variables (uses pre-compiled binary, no Docker required)

author: Konstantin Chukhlomin <mail@chuhlomin.com>

branding:
icon: file-text
color: purple

inputs:
template:
description: Path to template
required: true

vars:
description: Variables to use in template
required: false

vars_path:
description: Path to YAML file with variables
required: false

result_path:
description: Desired path to result file (optional)
required: false

timezone:
description: Timezone to use in `date` template function
required: false

outputs:
result:
description: Rendered file content
value: ${{ steps.run.outputs.result }}

runs:
using: composite
steps:
- name: Download binary
shell: bash
env:
GH_TOKEN: ${{ github.token }}
ACTION_REPO: ${{ github.action_repository }}
ACTION_REF: ${{ github.action_ref }}
run: |
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
[ "$OS" = "macos" ] && OS="darwin"
ARCH=$(echo "${{ runner.arch }}" | tr '[:upper:]' '[:lower:]')
[ "$ARCH" = "x64" ] && ARCH="amd64"
[ "$ARCH" = "arm" ] && ARCH="armv7"
EXT=""
[ "$OS" = "windows" ] && EXT=".exe"
BINARY="render-template_${OS}_${ARCH}${EXT}"
REPO="${ACTION_REPO:-chuhlomin/render-template}"
DEST="$RUNNER_TEMP/render-template"
mkdir -p "$DEST"
echo "Downloading ${BINARY} from ${REPO}@${ACTION_REF}"
if ! gh release download "${ACTION_REF}" \
--repo "${REPO}" \
--pattern "$BINARY" \
--dir "$DEST" 2>/dev/null; then
echo "'${ACTION_REF}' is not a release tag, resolving to latest '${ACTION_REF}.*'"
RESOLVED_TAG="$(gh release list \
--repo "${REPO}" \
--json tagName \
--jq "first(.[] | select(.tagName | startswith(\"${ACTION_REF}.\"))) | .tagName")"
[ -z "$RESOLVED_TAG" ] && echo "::error::No release found matching '${ACTION_REF}.*'" && exit 1
echo "Resolved to ${RESOLVED_TAG}"
if ! gh release download "${RESOLVED_TAG}" \
--repo "${REPO}" \
--pattern "$BINARY" \
--dir "$DEST"; then
echo "::error::No asset '${BINARY}' found in release '${RESOLVED_TAG}'"
exit 1
fi
fi
[ "$OS" != "windows" ] && chmod +x "$DEST/$BINARY"
echo "RENDER_TEMPLATE_BIN=$DEST/$BINARY" >> "$GITHUB_ENV"

- name: Run
id: run
shell: bash
env:
INPUT_TEMPLATE: ${{ inputs.template }}
INPUT_VARS: ${{ inputs.vars }}
INPUT_VARS_PATH: ${{ inputs.vars_path }}
INPUT_RESULT_PATH: ${{ inputs.result_path }}
INPUT_TIMEZONE: ${{ inputs.timezone }}
run: "${{ env.RENDER_TEMPLATE_BIN }}"
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/step-security/render-template
module github.com/chuhlomin/render-template

go 1.24
go 1.21

require (
github.com/caarlos0/env/v10 v10.0.0
Expand Down
Loading