Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEVOPS-389] Add input for specifying self hosted GitHub runner #114

Merged
merged 11 commits into from
Mar 11, 2024
35 changes: 19 additions & 16 deletions .github/workflows/aks-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ on:
type: string
description: "The branch, tag or SHA to checkout"
default: ${{ github.ref }}
githubRunner:
required: false
type: string
description: "The type of runner to use"
default: ${{ vars.CUSTOM_GITHUB_RUNNER || 'ubuntu-latest' }}
secrets:
azureClusterName:
required: true
Expand All @@ -92,7 +97,7 @@ on:
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
runs-on: ${{ inputs.githubRunner }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -225,7 +230,7 @@ jobs:
deploy:
name: AKS Deploy
needs: [build]
runs-on: ubuntu-latest
runs-on: ${{ inputs.githubRunner }}
continue-on-error: false
environment:
name: ${{ inputs.environment }}
Expand Down Expand Up @@ -337,29 +342,27 @@ jobs:
with:
k8-config-file-paths: deployments/k8s/config-${{ inputs.environment }}.yaml

- name: Update environment variables Kubernetes Secret
shell: pwsh
- name: Update .env Kubernetes secret
run: |
if (kubectl get secret | Select-String "${{ needs.build.outputs.configSecret }}") {
if kubectl get secret | grep -q "${{ needs.build.outputs.configSecret }}"; then
kubectl delete secret "${{ needs.build.outputs.configSecret }}"
}
kubectl create secret generic "${{ needs.build.outputs.configSecret }}" --from-env-file .env
fi
kubectl create secret generic "${{ needs.build.outputs.configSecret }}" --validate='warn' --from-env-file ${{ github.workspace }}/.env

- name: Update basic web authentication Kubernetes secret
shell: pwsh
run: |
if ( "${{ inputs.webAuthentication }}" -eq "true") {
if (!"${{ secrets.webAuthenticationUsername }}" -or !"${{ secrets.webAuthenticationPassword }}") {
Write-Output "::error::Please make sure the 'webAuthenticationUsername' and 'webAuthenticationPassword' GitHub environment secrets are set correctly."
if [[ "${{ inputs.webAuthentication }}" == "true" ]]; then
if [[ -z "${{ secrets.webAuthenticationUsername }}" ]] || [[ -z "${{ secrets.webAuthenticationPassword }}" ]]; then
echo "::error::Please make sure the 'webAuthenticationUsername' and 'webAuthenticationPassword' GitHub environment secrets are set correctly."
exit 1
}

if (kubectl get secret | Select-String "${{ needs.build.outputs.appName }}-basic-auth") {
fi
if kubectl get secret | grep -q "${{ needs.build.outputs.appName }}-basic-auth"; then
kubectl delete secret "${{ needs.build.outputs.appName }}-basic-auth"
}
fi
htpasswd -cb auth "${{ secrets.webAuthenticationUsername }}" "${{ secrets.webAuthenticationPassword }}"
kubectl create secret generic "${{ needs.build.outputs.appName }}-basic-auth" --from-file=auth
}
fi

- name: Create K8s Image Pull Secret
uses: Azure/k8s-create-secret@v4
Expand Down
Loading