/kubectl-action

Primary LanguageDockerfileMIT LicenseMIT

GitHub Action for Kubernetes CLI

Provides kubectl for GitHub Actions.

Usage

.github/workflows/push.yml

on: push
name: deploy
jobs:
  deploy:
    name: deploy to cluster
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: deploy to cluster
      uses: tinybeans/kubectl-action@v1.0.0
        config: ${{ secrets.KUBE_CONFIG_DATA }}
        command: set image --record deployment/my-app container=${{ github.repository }}:${{ github.sha }}
        # version: defaults to latest

    - name: verify deployment
      uses: tinybeans/kubectl-action@v1.0.0
      with:
        config: ${{ secrets.KUBE_CONFIG_DATA }}
        command: rollout status deployment/my-app
        version: v1.21.0 # explicit version

Arguments

commandrequired: Command you want to run, e.g. get pods

configrequired: A base64-encoded kubeconfig file with credentials for Kubernetes to access cluster. Get it by running the following command:

cat $HOME/.kube/config | base64

version: kubectl version with a 'v' prefix, e.g. v1.21.0. Defaults to latest kubectl version.

Note: Do not use kubectl config view as this will hide certificate-authority-data.