Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
theNullP0inter opened this issue Oct 12, 2021 · 0 comments

Comments

@theNullP0inter
Copy link

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

@theNullP0inter theNullP0inter changed the title How can I use multiple KUBECONFIG_FILE. Works with auto_deploy_on, fails with manual deploy How can I use multiple KUBECONFIG_FILE? - Works with auto_deploy_on, fails with manual deploy Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant