Skip to content

Latest commit

 

History

History
63 lines (49 loc) · 1.8 KB

File metadata and controls

63 lines (49 loc) · 1.8 KB

What is this?

  • Based on TelluIoT / kubernetes-env-to-secrets, we make it into a github action.

  • We are converting base64-encoded .env file stored in github secret into kubernetes ConfigMap or Secret yaml file



How to use with github action?

  • Create an .env file with the following content
NODE_ENV=prod

USERNAME=myusername
PASSWORD=mypassword
  • Encode .env
cat .env | base64

Tk9ERV9FTlY9cHJvZAoKVVNFUk5BTUU9bXl1c2VybmFtZQpQQVNTV09SRD1teXBhc3N3b3Jk
  • Put the base64-encoded string in github secret FireShot Capture 024 - Actions secrets - github com FireShot Capture 025 - Actions secrets - github com

  • Create .github/workflows/main.yml file. Below is only the snippet of it, see the full file here

jobs:
  test:
    ...

    steps:
      ...
      
      - id: 'generateConfigMap'
        name: Generate ConfigMap
        uses: timowang1991/github-actions-envfile-to-k8s-object@v1
        with:
          k8sName: 'test-configmap'
          k8sKind: 'ConfigMap' # or 'Secret'
          base64EncodedEnvString: ${{ secrets.ENV }}
      
      - name: Check ConfigMap
        run: echo "${{ steps.generateConfigMap.outputs.k8sObject }}"
  • you should get the following with echo "${{ steps.generateConfigMap.outputs.k8sObject }}"
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-configmap
type: Opaque
data:
  NODE_ENV: cHJvZA==
  USERNAME: bXl1c2VybmFtZQ==
  PASSWORD: bXlwYXNzd29yZA==