-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (62 loc) · 2.15 KB
/
scale-azure-container-app.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: "Scale Container App"
on:
workflow_dispatch:
inputs:
min_replicas:
description: "Container App Min Replicas"
required: true
default: "0"
schedule:
# ncrontab linux >> https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# Runs at 0 minutes past the hour, every 3 hours
- cron: "0 */3 * * *"
env:
max_replicas: 1
scale_down_min_replicas: 0
name: my-budget-app
resource_group: rg-my-budget-app
jobs:
scale:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Login Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIAL_AZURE_CONTAINER_APP }}
# Azure CLI 2.52.0 containerapp extension is in preview
# Required to install manually
- name: Deploy image to Azure Container App without Revision Suffix
uses: azure/CLI@v1
with:
azcliversion: 2.52.0
inlineScript: |
az extension add --name containerapp
az containerapp update \
--name ${{ env.name }} \
--resource-group ${{ env.resource_group }} \
--max-replicas ${{ env.max_replicas }} \
--min-replicas ${{ inputs.min_replicas }} \
> ${{ env.name }}.log.txt
scale-scheduled:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Login Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIAL_AZURE_CONTAINER_APP }}
# Azure CLI 2.52.0 containerapp extension is in preview
# Required to install manually
- name: Deploy image to Azure Container App without Revision Suffix
uses: azure/CLI@v1
with:
azcliversion: 2.52.0
inlineScript: |
az extension add --name containerapp
az containerapp update \
--name ${{ env.name }} \
--resource-group ${{ env.resource_group }} \
--max-replicas ${{ env.max_replicas }} \
--min-replicas ${{ env.scale_down_min_replicas }} \
> ${{ env.name }}.log.txt