Files
wlan-testing/.github/workflows/cloud-controller-build.yaml
2021-08-18 22:29:56 -04:00

118 lines
3.7 KiB
YAML

name: update cloud controllers build
defaults:
run:
shell: bash
env:
AWS_EKS_NAME: tip-wlan-main
AWS_DEFAULT_OUTPUT: json
AWS_DEFAULT_REGION: us-east-2
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_KEY }}
# Cloud SDK certs
CACERT: ${{ secrets.CACERT }}
CAKEY: ${{ secrets.CAKEY }}
# https://stackoverflow.com/questions/59977364/github-actions-how-use-strategy-matrix-with-script
testbeds: '[
{
"number": "01",
"version": "1.2.0"
},
{
"number": "02",
"version": "1.2.0"
}
]'
on:
workflow_dispatch:
jobs:
generate-matrix:
name: Generate matrix for build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: generate-matrix
id: set-matrix
run: |
echo '::set-output name=matrix::{"include":${{ env.testbeds }}}'
cloudsdk:
name: Update CloudSDK instances
runs-on: ubuntu-latest
needs: [ generate-matrix ]
strategy:
matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }}
fail-fast: false
steps:
- name: Checkout pki scripts repo
uses: actions/checkout@v2
with:
path: wlan-pki
repository: Telecominfraproject/wlan-pki-cert-scripts
- name: Checkout Cloud SDK repo
uses: actions/checkout@v2
with:
path: wlan-helm
repository: Telecominfraproject/wlan-cloud-helm
- name: Checkout helm values repo
uses: actions/checkout@v2
with:
path: toolsmith
repository: Telecominfraproject/Toolsmith
token: ${{ secrets.PAT_TOKEN }}
- name: Prepare environment deployment
run: |
mkdir -p ./wlan-pki/testCA/private ./wlan-pki/testCA/newcerts ./wlan-pki/generated
touch ./wlan-pki/testCA/index.txt
echo "01" > ./wlan-pki/testCA/serial.txt
echo "${{ env.CACERT }}" | base64 -d > ./wlan-pki/testCA/cacert.pem
echo "${{ env.CAKEY }}" | base64 -d > ./wlan-pki/testCA/private/cakey.pem
./toolsmith/helm-values/aws-cicd-testbed-deployment.yaml.sh ${{ matrix.number }} ${{ matrix.version }} > testbed-deployment.yaml
- name: Generate certs
working-directory: wlan-pki
run: |
./generate_all.sh true
./copy-certs-to-helm.sh "../wlan-helm"
- name: Fetch kubeconfig
run: |
aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }}
- name: Deploy Cloud SDK
working-directory: wlan-helm/tip-wlan
run: |
helm dependency update
helm upgrade --install tip . -f ../../testbed-deployment.yaml --create-namespace --namespace nola-${{ matrix.number }} --wait --timeout 20m
- name: Show resource state on deployment failure
if: failure()
run: |
kubectl get pods --namespace nola-${{ matrix.number }}
kubectl get services --namespace nola-${{ matrix.number }}
kubectl get persistentvolumeclaims --namespace nola-${{ matrix.number }}
- name: Describe pods on deployment failure
if: failure()
run: |
kubectl describe pods --namespace nola-${{ matrix.number }}
- name: Describe services on deployment failure
if: failure()
run: |
kubectl describe services --namespace nola-${{ matrix.number }}
- name: Describe persistentvolumeclaims on deployment failure
if: failure()
run: |
kubectl describe persistentvolumeclaims --namespace nola-${{ matrix.number }}
- name: Rollback Cloud SDK
if: failure()
working-directory: wlan-helm/tip-wlan
run: |
helm rollback tip --namespace nola-${{ matrix.number }} --wait --timeout 20m