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

GitHub Action

Helm Deploy Release

v1.0.2

Helm Deploy Release

anchor

Helm Deploy Release

Deploys a helm chart to Kubernetes

Installation

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

              

- name: Helm Deploy Release

uses: SergkeiM/[email protected]

Learn more about this action in SergkeiM/helm-deploy

Choose a version

Helm Action

Deploys a helm chart using GitHub actions.

Parameters

Inputs

Required and Optional Inputs.

  • release: Helm release name. Will be combined with track if set. (required)
  • namespace: Kubernetes namespace name. (required)
  • chart: Helm chart path. If set to "app" this will use the built in helm chart found in this repository. (required)
  • values: Value files to apply to the helm chart. Expects a JSON encoded array or a string.
  • task: Task name. If the task is "remove" it will remove the configured helm release.
  • dry-run: Helm dry-run option.
  • secrets: Secret variables to include in value file interpolation. Expects a JSON encoded map.
  • vars: Variables to include in value file interpolation. Expects a JSON encoded map.
  • version: Version of the app, usually commit sha works here.
  • chart-version: The version of the helm chart you want to deploy (distinct from app version)
  • timeout: specify a timeout for helm deployment
  • atomic: If true, upgrade process rolls back changes made in case of failed upgrade. Defaults to true.

Environment

  • KUBECONFIG_FILE: Kubeconfig file for Kubernetes cluster access.

Value file interpolation

The following syntax allows variables to be used in value files:

  • ${{ secrets.KEY }}: References secret variables passed in the secrets input action.
  • ${{ vars.KEY }}: References secret variables passed in the secrets input action.

Environment variable substitution

Automatically substituting environment variables in values files.

  • ${MY_VAR}: References env variable passed in env.
  • $MY_VAR: References env variable passed in env.
  • ${MY_VAR:-default}: References env variable passed in env, if not set uses default value.

Example

# .github/workflows/deploy.yml
name: Deploy
on:
  push:
    branches: ["master"]

jobs:
  deployment:
    runs-on: 'ubuntu-latest'
    steps:
    - uses: actions/checkout@v3

    - name: 'Deploy'
      uses: 'froxz/helm-deploy@v1'
      with:
        release: 'nginx'
        namespace: 'default'
        chart: 'app'
        values: >-
        [
          "values.yaml", 
          "values.production.yaml"
        ]
      env:
        KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'

Example pr cleanup

If you are creating an environment per pull request with Helm you may have the issue where pull request environments like pr123 sit around in your cluster. By using GitHub actions we can clean those up by listening for pull request close events.

# .github/workflows/pr-cleanup.yml
name: PRCleanup
on:
  pull_request:
    types: [closed]

jobs:
  deployment:
    runs-on: 'ubuntu-latest'
    steps:
    - name: 'Deploy'
      uses: 'froxz/helm-deploy@v1'
      with:
        # Task remove means to remove the helm release.
        task: 'remove'
        release: 'review-myapp-${{ github.event.pull_request.number }}'
        version: '${{ github.sha }}'
        chart: 'app'
        namespace: 'example-helm'
      env:
        KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'