2021-09-02 22:05:17 +02:00
|
|
|
---
|
2021-06-29 16:33:01 +02:00
|
|
|
name: QA Deploy
|
|
|
|
|
2021-09-02 22:05:17 +02:00
|
|
|
on:
|
2021-06-29 16:33:01 +02:00
|
|
|
workflow_dispatch:
|
2021-08-10 16:28:21 +02:00
|
|
|
inputs:
|
|
|
|
image_extension:
|
|
|
|
description: "Image tag extension"
|
|
|
|
required: false
|
2021-06-29 16:33:01 +02:00
|
|
|
|
|
|
|
env:
|
2021-08-27 17:40:35 +02:00
|
|
|
_QA_CLUSTER_RESOURCE_GROUP: "bitwarden-devops"
|
|
|
|
_QA_CLUSTER_NAME: "dev-aks"
|
|
|
|
_QA_K8S_NAMESPACE: "bw-qa"
|
|
|
|
_QA_K8S_APP_NAME: "bw-web"
|
2021-06-29 16:33:01 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
deploy:
|
2021-08-10 16:28:21 +02:00
|
|
|
name: Deploy QA Web
|
2021-09-21 18:37:17 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2021-06-29 16:33:01 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout Repo
|
2021-09-02 22:05:17 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
2021-06-29 16:33:01 +02:00
|
|
|
|
|
|
|
- name: Setup
|
|
|
|
run:
|
|
|
|
export PATH=$PATH:~/work/web/web
|
|
|
|
|
|
|
|
- name: Login to Azure
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
|
|
|
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
|
|
|
|
with:
|
|
|
|
keyvault: "bitwarden-qa-kv"
|
|
|
|
secrets: "dev-aks-kubectl-credentials"
|
|
|
|
|
|
|
|
- name: Login to dev-aks-kubectl SP
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ env.dev-aks-kubectl-credentials }}
|
|
|
|
|
|
|
|
- name: Setup AKS access
|
|
|
|
env:
|
|
|
|
USER_ID: ${{ env.qa-kubectl-managed-identity-clientId }}
|
|
|
|
run: |
|
|
|
|
echo "---az install---"
|
|
|
|
az aks install-cli --install-location ./kubectl --kubelogin-install-location ./kubelogin
|
|
|
|
echo "---az get-creds---"
|
2021-08-27 17:40:35 +02:00
|
|
|
az aks get-credentials -n $_QA_CLUSTER_NAME -g $_QA_CLUSTER_RESOURCE_GROUP
|
2021-06-29 16:33:01 +02:00
|
|
|
|
2021-08-10 16:28:21 +02:00
|
|
|
- name: Get image tag
|
|
|
|
id: image_tag
|
2021-06-29 16:33:01 +02:00
|
|
|
run: |
|
2021-08-10 16:28:21 +02:00
|
|
|
IMAGE_TAG=$(echo "$GITHUB_REF" | awk '{split($0, a, "/"); print a[3];}')
|
2021-09-24 18:28:37 +02:00
|
|
|
TAG_EXTENSION=${{ github.event.inputs.image_extension }}
|
2021-08-10 16:28:21 +02:00
|
|
|
|
|
|
|
if [[ $TAG_EXTENSION ]]; then
|
|
|
|
IMAGE_TAG=$IMAGE_TAG-$TAG_EXTENSION
|
2021-09-02 22:05:17 +02:00
|
|
|
fi
|
2021-08-10 16:28:21 +02:00
|
|
|
echo "::set-output name=value::$IMAGE_TAG"
|
|
|
|
|
|
|
|
- name: Deploy Web image
|
|
|
|
env:
|
|
|
|
IMAGE_TAG: ${{ steps.image_tag.outputs.value }}
|
|
|
|
run: |
|
2021-08-27 17:40:35 +02:00
|
|
|
kubectl set image -n $_QA_K8S_NAMESPACE deployment/web web=bitwardenqa.azurecr.io/web:$IMAGE_TAG --record
|
2021-08-27 18:12:50 +02:00
|
|
|
kubectl rollout restart -n $_QA_K8S_NAMESPACE deployment/web
|
2021-08-27 17:40:35 +02:00
|
|
|
kubectl rollout status deployment/web -n $_QA_K8S_NAMESPACE
|