Skip to content

Go Modeler for File Templates

Actions
Create and compile your file templates for deploy, Github Step Summary and others with ease
v1
Latest
Star (1)

Go Modeler for GitHub Action

GoModeler is a small CLI to facilitate the compilation of templates using the go template engine.

See more: https://github.com/toolsascode/gomodeler

Changelog

Please refer to the release page for the latest release notes.

Usage

- uses: toolsascode/gomodeler-action@v1
  with:
    # Expected log level in application output.
    # Currently the following options are supported: debug, info, warn, error, fatal or panic
    # Default: info
    log-level: info
    # List of environment variables in key=value format
    # Default: ''
    environments: |
        key=value
    # Environment variables file in YAML or JSON format.
    # Default: ''
    environment-file: /path/to/envFile.yaml
    # gotemplate code block to be rendered
    # Default: ''
    template: |
        {{ .key }}
    # List of template files for rendering.
    # Default: ''
    template-file: /path/to/templates/file.ext.gotmpl
    # Path of template files for rendering.
    # Default: ''
    template-path: /path/to/templates
    # The path where the rendered files will be stored.
    # Default: "./outputs"
    output-path: /path/to/outputs
    # Add rendered content to GITHUB_STEP_SUMMARY output.
    # Default: false
    github-step-summary: false

Examples

Render templates
  • This model is useful for those who only expect to compile the file and use the file for other tasks.
- uses: toolsascode/gomodeler-action@v1
  with:
    log-level: info
    environment-file: /path/to/envFile.yaml
    template-path: /path/to/templates
    output-path: /path/to/outputs
Add rendered content to GitHub Step Summary
  • In this case, in addition to compiling, the file is automatically added to GITHUB_STEP_SUMMARY.
- uses: toolsascode/gomodeler-action@v1
  with:
    log-level: info
    environment-file: /path/to/envFile.yaml
    template-path: /path/to/templates
    output-path: /path/to/outputs
    github-step-summary: true
Customizing the GitHub Actions Summary
  • A small example of how you can create your custom template file.
  • In this case, in addition to compiling, the file is automatically added to GITHUB_STEP_SUMMARY.
  1. Create the Template file: summary.md.gotmpl
## {{ .title }}
{{ if or (empty .active_details) (.active_details | default "true" | bool) }}
<details>
    <summary><b>{{ .subtitle | default "Output" }}</b></summary>

{{ if or (empty .split_file) (not .split_file | default "false" | bool) }}
'``{{ .extension | default "yaml" }}
{{ include .filename | trim }}
'``
{{ else }}
'``{{ .extension | default "yaml" }}
{{ range (include .filename) | trim | arrayStr -}}
{{- $file := . }}
{{- if not (empty "$file") }}
{{- $file }}
{{- end }}
{{ end -}}
'``
{{ end }}
</details>
{{ end -}}
  1. Add Workflow
  - name: Checkout
    uses: actions/checkout@v4
  - uses: dorny/paths-filter@v3
    id: filter
    with:
      list-files: shell
      filters: |
        files:
          - added|modified: '*.go'

  - name: Generate Output files
    run: |
      echo "${{ steps.filter.outputs.files }}" > ./files.out

  - name: Step Summary - Flow files changes
    uses: toolsascode/gomodeler-action@v1
    with:
      log-level: debug
      environments: |
        title=Files Changes
        subtitle=Output
        extension=shell
        active_details=true
        split_file=true
        filename=./files.out
      template-file: ./templates/summary.md.gotmpl
      github-step-summary: true

Others

See example: https://github.com/toolsascode/gomodeler-action/actions/runs/10893938906

License

The scripts and documentation in this project are released under the MIT License

Go Modeler for File Templates is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Create and compile your file templates for deploy, Github Step Summary and others with ease
v1
Latest

Go Modeler for File Templates is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.