-
Notifications
You must be signed in to change notification settings - Fork 25
53 lines (46 loc) · 1.95 KB
/
kedaScaleTest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: KEDA Scale self hosted
on:
workflow_dispatch:
env:
AZ_STORAGE_ACCOUNT: aca2keda2scaler126
AZ_QUEUE_NAME: gh-runner-scaler
jobs:
#External Job to create and associate workflow with a unique QueueId on Azure queue to scale up KEDA
scale-keda-queue-up:
runs-on: ubuntu-latest
steps:
- name: "Login via Azure CLI"
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: scale up self hosted
id: scaleJob
run: |
OUTPUT=$(az storage message put --queue-name "${{ env.AZ_QUEUE_NAME }}" --content "${{ github.run_id }}" --account-name "${{ env.AZ_STORAGE_ACCOUNT }}")
echo "::set-output name=scaleJobId::$(echo "$OUTPUT" | grep "id" | sed 's/^.*: //' | sed 's/,*$//g')"
echo "::set-output name=scaleJobPop::$(echo "$OUTPUT" | grep "popReceipt" | sed 's/^.*: //' | sed 's/,*$//g')"
outputs:
scaleJobId: ${{ steps.scaleJob.outputs.scaleJobId }}
scaleJobPop: ${{ steps.scaleJob.outputs.scaleJobPop }}
#Subsequent Jobs runs-on [self-hosted]. Job1, Job2, JobN etc etc
testRunner:
needs: scale-keda-queue-up
runs-on: [self-hosted]
steps:
- uses: actions/[email protected]
- name: Install Terraform
uses: hashicorp/[email protected]
- name: Display Terraform Version
run: terraform --version
- name: Display Azure-CLI Version
run: az --version
- name: Delay runner finish (2min)
run: sleep 2m
#Remove unique QueueId on Azure queue associated with workflow as final step to scale down KEDA
- name: "Login via Azure CLI"
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: scale down self hosted
run: |
az storage message delete --id ${{needs.scale-keda-queue-up.outputs.scaleJobId}} --pop-receipt ${{needs.scale-keda-queue-up.outputs.scaleJobPop}} --queue-name "${{ env.AZ_QUEUE_NAME }}" --account-name "${{ env.AZ_STORAGE_ACCOUNT }}"