Skip to content

Commit

Permalink
change kubeconfig to multiline env var
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlincecum committed Mar 1, 2024
1 parent ce46b1d commit c6ceedb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/build-deploy-elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,26 @@ jobs:
id: prepare_kubeconfig
if: ${{ !inputs.skip_deploy && inputs.cloud_deploy }}
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
echo "${{ secrets.KUBE_CONFIG }}" > ${{ github.workspace }}/kubeconfig
if [ -n "${{ env.TOKEN }}" ]; then
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ~/.kube/config
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ${{ github.workspace }}/kubeconfig
fi
## set kubeconfig contents to env variable in gh
KUBECONFIG_CONTENT=$(cat ${{ github.workspace }}/kubeconfig)
echo "KUBECONFIG_CONTENT<<EOF" >> $GITHUB_ENV
echo "$KUBECONFIG_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash

- name: Deploy to cloud
uses: WyriHaximus/github-action-helm3@v2
uses: WyriHaximus/github-action-helm3@v3
if: ${{ inputs.cloud_deploy && !inputs.skip_deploy }}
id: deploy
continue-on-error: true
with:
exec: helm upgrade ${{ env.REPO_NAME }} ./helm --install --namespace=${{ inputs.env }} --values=./helm/env/${{ inputs.env }}.values.yaml
exec: helm upgrade ${{ env.REPO_NAME }} ./.helm/app/ --install --wait --atomic --namespace=${{ inputs.env }} --values=./.helm/app/values.yaml
kubeconfig: ${{ env.KUBECONFIG_CONTENT }}
overrule_existing_kubeconfig: 'true'

- name: Deploy to local from bastion
if: ${{ !inputs.cloud_deploy && !inputs.skip_deploy }}
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/build-deploy-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,26 @@ jobs:
id: prepare_kubeconfig
if: ${{ !inputs.skip_deploy && inputs.cloud_deploy }}
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
echo "${{ secrets.KUBE_CONFIG }}" > ${{ github.workspace }}/kubeconfig
if [ -n "${{ env.TOKEN }}" ]; then
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ~/.kube/config
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ${{ github.workspace }}/kubeconfig
fi
## set kubeconfig contents to env variable in gh
KUBECONFIG_CONTENT=$(cat ${{ github.workspace }}/kubeconfig)
echo "KUBECONFIG_CONTENT<<EOF" >> $GITHUB_ENV
echo "$KUBECONFIG_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash

- name: Deploy to cloud
uses: WyriHaximus/github-action-helm3@v2
uses: WyriHaximus/github-action-helm3@v3
if: ${{ inputs.cloud_deploy && !inputs.skip_deploy }}
id: deploy
continue-on-error: true
with:
exec: helm upgrade ${{ env.REPO_NAME }} ./helm --install --namespace=${{ inputs.env }} --values=./helm/env/${{ inputs.env }}.values.yaml
exec: helm upgrade ${{ env.REPO_NAME }} ./.helm/app/ --install --wait --atomic --namespace=${{ inputs.env }} --values=./.helm/app/values.yaml
kubeconfig: ${{ env.KUBECONFIG_CONTENT }}
overrule_existing_kubeconfig: 'true'

- name: Deploy to local from bastion
if: ${{ !inputs.cloud_deploy && !inputs.skip_deploy }}
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/build-deploy-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,26 @@ jobs:
id: prepare_kubeconfig
if: ${{ !inputs.skip_deploy && inputs.cloud_deploy }}
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
echo "${{ secrets.KUBE_CONFIG }}" > ${{ github.workspace }}/kubeconfig
if [ -n "${{ env.TOKEN }}" ]; then
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ~/.kube/config
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ${{ github.workspace }}/kubeconfig
fi
## set kubeconfig contents to env variable in gh
KUBECONFIG_CONTENT=$(cat ${{ github.workspace }}/kubeconfig)
echo "KUBECONFIG_CONTENT<<EOF" >> $GITHUB_ENV
echo "$KUBECONFIG_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash

- name: Deploy to cloud
uses: WyriHaximus/github-action-helm3@v2
uses: WyriHaximus/github-action-helm3@v3
if: ${{ inputs.cloud_deploy && !inputs.skip_deploy }}
id: deploy
continue-on-error: true
with:
exec: helm upgrade ${{ env.REPO_NAME }} ./helm --install --namespace=${{ inputs.env }} --values=./helm/env/${{ inputs.env }}.values.yaml
exec: helm upgrade ${{ env.REPO_NAME }} ./.helm/app/ --install --wait --atomic --namespace=${{ inputs.env }} --values=./.helm/app/values.yaml
kubeconfig: ${{ env.KUBECONFIG_CONTENT }}
overrule_existing_kubeconfig: 'true'

- name: Deploy to local from bastion
if: ${{ !inputs.cloud_deploy && !inputs.skip_deploy }}
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/build-deploy-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,26 @@ jobs:
id: prepare_kubeconfig
if: ${{ !inputs.skip_deploy && inputs.cloud_deploy }}
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
echo "${{ secrets.KUBE_CONFIG }}" > ${{ github.workspace }}/kubeconfig
if [ -n "${{ env.TOKEN }}" ]; then
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ~/.kube/config
sed -i 's|token:.*|token: ${{ env.TOKEN }}|' ${{ github.workspace }}/kubeconfig
fi
## set kubeconfig contents to env variable in gh
KUBECONFIG_CONTENT=$(cat ${{ github.workspace }}/kubeconfig)
echo "KUBECONFIG_CONTENT<<EOF" >> $GITHUB_ENV
echo "$KUBECONFIG_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash

- name: Deploy to cloud
uses: WyriHaximus/github-action-helm3@v2
uses: WyriHaximus/github-action-helm3@v3
if: ${{ inputs.cloud_deploy && !inputs.skip_deploy }}
id: deploy
continue-on-error: true
with:
exec: helm upgrade ${{ env.REPO_NAME }} ./helm --install --namespace=${{ inputs.env }} --values=./helm/env/${{ inputs.env }}.values.yaml
exec: helm upgrade ${{ env.REPO_NAME }} ./.helm/app/ --install --wait --atomic --namespace=${{ inputs.env }} --values=./.helm/app/values.yaml
kubeconfig: ${{ env.KUBECONFIG_CONTENT }}
overrule_existing_kubeconfig: 'true'

- name: Deploy to local from bastion
if: ${{ !inputs.cloud_deploy && !inputs.skip_deploy }}
Expand Down

0 comments on commit c6ceedb

Please sign in to comment.