-
Notifications
You must be signed in to change notification settings - Fork 5
47 lines (41 loc) · 1.32 KB
/
gh_runner-scheduler.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
name: GitHub Runner Job AutoScaler
on:
workflow_dispatch:
schedule:
- cron: '0 07 * * MON-FRI'
- cron: '0 16 * * MON-FRI'
permissions:
id-token: write
contents: read
env:
resource-group: 'io-p-github-runner-rg'
job-name: 'io-p-infra-github-runner-job'
maximum_replica: 10
jobs:
scheduler:
runs-on: ubuntu-22.04
environment: prod-runner
steps:
- name: Azure Login
id: login
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Increase minimum replicas
if: github.event.schedule == '0 07 * * MON-FRI'
run: |
az containerapp job update \
--resource-group ${{ env.resource-group }} \
--name ${{ env.job-name }} \
--min-executions 1 \
--max-executions ${{ env.maximum_replica }}
- name: Decrease minimum replicas
if: github.event.schedule == '0 16 * * MON-FRI'
run: |
az containerapp job update \
--resource-group ${{ env.resource-group }} \
--name ${{ env.job-name }} \
--min-executions 0 \
--max-executions ${{ env.maximum_replica }}