|
| 1 | +name: cluster-auth |
| 2 | +description: Generate GH token and log in to GKE/ROSA or decrypt kubeconfig |
| 3 | +inputs: |
| 4 | + platform: { required: true, description: gke | rosa | custom } |
| 5 | + auth-data: { required: false, description: base64-encrypted kubeconfig } |
| 6 | + |
| 7 | +outputs: |
| 8 | + token: |
| 9 | + description: GitHub token |
| 10 | + value: ${{ steps.generate-github-token.outputs.token }} |
| 11 | + |
| 12 | +env: |
| 13 | + GH_APP_ID: {} |
| 14 | + GH_APP_KEY: {} |
| 15 | + GKE_CLUSTER_NAME: {} |
| 16 | + GKE_CLUSTER_LOC: {} |
| 17 | + GKE_WIP: {} |
| 18 | + GKE_SA: {} |
| 19 | + ROSA_URL: {} |
| 20 | + ROSA_USER: {} |
| 21 | + ROSA_PASS: {} |
| 22 | + CLUSTER_NAME: {} |
| 23 | + |
| 24 | +runs: |
| 25 | + using: "composite" |
| 26 | + steps: |
| 27 | + - name: Generate GitHub token |
| 28 | + uses: tibdex/github-app-token@v2 |
| 29 | + id: generate-github-token |
| 30 | + with: |
| 31 | + app_id: ${{ env.GH_APP_ID }} |
| 32 | + private_key: ${{ env.GH_APP_KEY }} |
| 33 | + |
| 34 | + - name: Authenticate to GKE |
| 35 | + if: inputs.platform == 'gke' && inputs.auth-data == '' |
| 36 | + uses: ./.github/actions/gke-login |
| 37 | + with: |
| 38 | + cluster-name: ${{ env.GKE_CLUSTER_NAME }} |
| 39 | + cluster-location: ${{ env.GKE_CLUSTER_LOC }} |
| 40 | + workload-identity-provider: ${{ env.GKE_WIP }} |
| 41 | + service-account: ${{ env.GKE_SA }} |
| 42 | + |
| 43 | + - name: Authenticate to OpenShift |
| 44 | + if: inputs.platform == 'rosa' && inputs.auth-data == '' |
| 45 | + uses: redhat-actions/oc-login@v1 |
| 46 | + with: |
| 47 | + openshift_server_url: ${{ env.ROSA_URL }} |
| 48 | + openshift_username: ${{ env.ROSA_USER }} |
| 49 | + openshift_password: ${{ env.ROSA_PASS }} |
| 50 | + |
| 51 | + - name: Set up Teleport |
| 52 | + if: inputs.platform == 'eks' |
| 53 | + uses: teleport-actions/setup@v1 |
| 54 | + with: |
| 55 | + version: 17.2.2 |
| 56 | + |
| 57 | + - name: Authenticate with Teleport |
| 58 | + if: inputs.platform == 'eks' && inputs.auth-data == '' |
| 59 | + uses: teleport-actions/auth-k8s@v2 |
| 60 | + with: |
| 61 | + proxy: camunda.teleport.sh:443 |
| 62 | + token: ${{ env.TOKEN }} |
| 63 | + kubernetes-cluster: ${{ env.CLUSTER_NAME }} |
| 64 | + |
| 65 | + - name: Authenticate via var |
| 66 | + if: inputs.auth-data != '' |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + mkdir -p "$HOME/.kube" |
| 70 | + echo "${{ inputs.auth-data }}" | base64 -d > enc.cfg |
| 71 | + openssl enc -aes-256-cbc -d -in enc.cfg -out "$HOME/.kube/config" \ |
| 72 | + -pass pass:"${{ steps.generate-github-token.outputs.token }}" -pbkdf2 |
| 73 | + rm enc.cfg |
| 74 | + chmod 600 "$HOME/.kube/config" |
0 commit comments