Sign inSign up

chuhlomin/render-template

By chuhlomin

•Updated 6 months ago

GitHub Action to render file based on template and passed variables

Image
1

5M+

chuhlomin/render-template repository overview

⁠Render Template⁠

main release DockerHub

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

⁠Inputs

NameDescriptionRequired
templatePath to templatetrue
varsVariables to use in template (in YAML format)false
vars_pathPath to YAML file with variablesfalse
result_pathDesired path to result filefalse

You must set at least vars or vars_path.
You may set both of them (vars values will precede over vars_path).

⁠Outputs

NameDescription
resultRendered file content

⁠Example

kube.template.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .deployment }}
  labels:
    app: {{ .app }}
spec:
  replicas: 3
  selector:
    matchLabels:
      app: {{ .app }}
  template:
    metadata:
      labels:
        app: {{ .app }}
    spec:
      containers:
      - name: {{ .app }}
        image: {{ .image }}
        ports:
        - containerPort: 80

.github/workflows/main.yml

name: main
on:
  push:
    branches:
      - main
env:
  DOCKER_IMAGE: username/image
  DEPLOYMENT_NAME: nginx-deployment
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      <...>

      - name: Render template
        id: render_template
        uses: chuhlomin/[email protected]
        with:
          template: kube.template.yml
          vars: |
            image: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
            deployment: ${{ env.DEPLOYMENT_NAME }}
            app: nginx

      - name: Deploy
        timeout-minutes: 4
        run: |-
          echo '${{ steps.render_template.outputs.result }}' | kubectl apply -f -
          kubectl rollout status deployment/$DEPLOYMENT_NAME

Tag summary

Content type

Image

Digest

sha256:496f2d449…

Size

2.2 MB

Last updated

6 months ago

docker pull chuhlomin/render-template