You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Render Template
v1.3
GitHub Action to render file based on template and passed variables.
template
– path to Go template filevars
– template variables in YAML format
result
– rendered template
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: Render template
id: render_template
uses: chuhlomin/render-template@v1.2
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