Skip to content

How can I use multiple KUBECONFIG_FILE? - Works with auto_deploy_on, fails with manual deploy #58

@theNullP0inter

Description

@theNullP0inter

I have 2 k8s clusters - one for production, one for review & staging environment.

Functionality I'm trying to achieve:

  1. Deploy to test cluster on merge to test branch
  2. Manually deploy master to production using the deliverybot web-app ( https://app.deliverybot.dev/ )

This is how my config looks like.

.github/workflows/cd.yml

name: 'Deploy'
on: [deployment]

jobs:
  deployment:
    runs-on: 'ubuntu-latest'
    steps:
      - name: 'Checkout'
        uses: 'actions/checkout@v1'

      - name: Set Test Kubeconfig
        if: github.ref == 'refs/heads/test'
        run: |
          echo "KUBECONFIG_FILE<<EOF" >> $GITHUB_ENV
          echo "${{ secrets.TEST_KUBECONFIG }}" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

      - name: Set Production Kubeconfig
        if: github.ref == 'refs/heads/master'
        run: |
          echo "KUBECONFIG_FILE<<EOF" >> $GITHUB_ENV
          echo "${{ secrets.PRODUCTION_KUBECONFIG }}" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

      - name: 'Deploy'
        # Parameters are pulled directly from the GitHub deployment event so the
        # configuration for the job here is very minimal.
        uses: 'deliverybot/helm@master'
        with:
          token: '${{ github.token }}'
          secrets: '${{ toJSON(secrets) }}'
          version: '${{ github.sha }}'
          chart: './charts/my-app'

.github/deploy.yml


production:
  production_environment: true
  required_contexts: []
  environment: production
  description: "Production Deployment"
  payload:
    value_files: ["./values/my-app/values.common.yaml", "./values/my-app/values.production.yaml"]
    # Remove the canary deployment if it exists when doing a full prod deploy.
    remove_canary: true
    release: production-my-app
    namespace: production
    track: stable
    helm: helm3


test:
  auto_deploy_on: refs/heads/test
  required_contexts: []
  environment: test
  description: "Test deployment"
  payload:
    value_files: ["./values/my-app/values.common.yaml", "./values/my-app/values.test.yaml"]
    remove_canary: true
    release: test-my-app
    namespace: test
    track: stable
    helm: helm3

This works when I push/merge to test branch.

image

But when i trigger a deployment from the deliverybot web-app targetting test/master , It skips the steps that sets kubeconfig

image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions