Skip to content

Commit

Permalink
Test deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mattops committed Aug 30, 2023
1 parent b0b2a01 commit 74d907f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 43 deletions.
37 changes: 18 additions & 19 deletions .github/actions/cloud-platform-auth/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
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}
22 changes: 3 additions & 19 deletions .github/actions/cloud-platform-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 74d907f

Please sign in to comment.