diff --git a/.github/actions/cloud-platform-auth/action.yml b/.github/actions/cloud-platform-auth/action.yml index 65d1d6d..d671622 100644 --- a/.github/actions/cloud-platform-auth/action.yml +++ b/.github/actions/cloud-platform-auth/action.yml @@ -2,30 +2,29 @@ name: Cloud Platform Auth description: Authenticate with MOJ Cloud Platform inputs: - api: - description: The KUBE_ENV_API - required: true - cert: - description: The KUBE_CERT - required: true - cluster: - description: The KUBE_CLUSTER - required: true - namespace: - description: The KUBE_NAMESPACE - required: true - token: - description: The KUBE_TOKEN + github_environment: + description: Github environment containing creds for cloudplatform required: true runs: + environment: + name: ${{ inputs.github_environment }} using: composite steps: + - name: Setup env vars + if: inputs.github_environment == 'development' + shell: bash + run: | + echo "KUBE_ENV_API=${{ secrets.DEVELOPMENT_KUBE_ENV_API }}" >> $GITHUB_ENV + echo "KUBE_CERT=${{ secrets.DEVELOPMENT_KUBE_CERT }}" >> $GITHUB_ENV + echo "KUBE_CLUSTER=${{ secrets.DEVELOPMENT_KUBE_CLUSTER }}" >> $GITHUB_ENV + echo "KUBE_NAMESPACE=${{ secrets.DEVELOPMENT_KUBE_NAMESPACE }}" >> $GITHUB_ENV + echo "KUBE_TOKEN=${{ secrets.DEVELOPMENT_KUBE_TOKEN }}" >> $GITHUB_ENV - name: Authenticate shell: bash run: | - echo "${{ inputs.cert }}" > ca.crt - kubectl config set-cluster ${{ inputs.cluster }} --certificate-authority=./ca.crt --server=${{ inputs.api }} - kubectl config set-credentials cd-serviceaccount --token=${{ inputs.token }} - kubectl config set-context ${{ inputs.cluster }} --cluster=${{ inputs.cluster }} --user=cd-serviceaccount --namespace=${{ inputs.namespace }} - kubectl config use-context ${{ inputs.cluster }} \ No newline at end of file + echo "${KUBE_CERT}" > ca.crt + kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=${KUBE_ENV_API} + kubectl config set-credentials cd-serviceaccount --token=${KUBE_TOKEN} + kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=cd-serviceaccount --namespace=${KUBE_NAMESPACE} + kubectl config use-context ${KUBE_CLUSTER} \ No newline at end of file diff --git a/.github/actions/cloud-platform-deploy/action.yml b/.github/actions/cloud-platform-deploy/action.yml index 96e367c..0b098f6 100644 --- a/.github/actions/cloud-platform-deploy/action.yml +++ b/.github/actions/cloud-platform-deploy/action.yml @@ -8,20 +8,8 @@ inputs: version: description: The version of the service to deploy required: true - api: - description: The KUBE_ENV_API - required: true - cert: - description: The KUBE_CERT - required: true - cluster: - description: The KUBE_CLUSTER - required: true - namespace: - description: The KUBE_NAMESPACE - required: true - token: - description: The KUBE_TOKEN + github_environment: + description: Github environment containing creds for cloudplatform required: true runs: @@ -32,11 +20,7 @@ runs: - name: Authenticate uses: ./.github/actions/cloud-platform-auth with: - api: ${{ inputs.api }} - cert: ${{ inputs.cert }} - cluster: ${{ inputs.cluster }} - namespace: ${{ inputs.namespace }} - token: ${{ inputs.token }} + github_environment: ${{ inputs.github_environment }} - name: Deploy shell: bash diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a28cafb..bb041cf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,11 +49,7 @@ jobs: - name: Deploy to Cloud Platform uses: ./.github/actions/cloud-platform-deploy with: + github_environment: ${{ inputs.github_environment }} environment: ${{ inputs.environment }} version: ${{ inputs.version }} - api: ${{ secrets.KUBE_ENV_API }} - cert: ${{ secrets.KUBE_CERT }} - cluster: ${{ secrets.KUBE_CLUSTER }} - namespace: ${{ secrets.KUBE_NAMESPACE }} - token: ${{ secrets.KUBE_TOKEN }}