Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
sliders

GitHub Action

Jinja2 Action

v1.2.0

Jinja2 Action

sliders

Jinja2 Action

Use the Jinja2 templating engine on your workflow

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Jinja2 Action

uses: cuchi/[email protected]

Learn more about this action in cuchi/jinja2-action

Choose a version

release marketplace

Jinja2 is a fast and straightforward templating engine. You can use this action to easily run it in your GitHub workflows.

Using input variables

- name: Setup nginx
  uses: cuchi/[email protected]
  with:
    template: infra/nginx.conf.j2
    output_file: infra/nginx.conf
    strict: true
    variables: |
      server_host=staging.example.com
      timeout=30s

Using data files

- name: Setup nginx
  uses: cuchi/[email protected]
  with:
    template: infra/nginx.conf.j2
    output_file: infra/nginx.conf
    data_file: staging_config.json
    data_format: json # Will try to guess from the extension instead (unnecessary in this case)

Using environment variables

- name: Setup nginx
  uses: cuchi/[email protected]
  with:
    template: infra/nginx.conf.j2
    output_file: infra/nginx.conf
  env:
    SERVER_HOST: staging.example.com

Environment variables are used this way in the template file:

{{ env['SERVER_HOST'] }} <-- This is always strict
{{ env.get('SERVER_HOST') }} <-- This is never strict, and displays `None` if you don't specify a default value

See also