-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.94 KB
/
publish-batch-apps.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Terra Data Update Batch CI/CD
env:
BATCH_ACCOUNT_RG: RG-Cosmo
BATCH_ACCOUNT_NAME: istatcosmobatches
BATCH_APP_PACKAGE_NAME_DATA_UPDATE: cosmoDataUpdate
BATCH_APP_PACKAGE_NAME_DATA_UPDATE_SET_DEFAULT: 1
BATCH_APP_PACKAGE_NAME_PREPARE_NODE: preparenode
BATCH_APP_PACKAGE_NAME_PREPARE_NODE_SET_DEFAULT: 1
PUBLISH_PREPARE_NODE: 1
USE_RUN_NUMBER_AS_VERSION: 1
on:
push:
branches: [ main ]
paths:
- terra-update-batch/**
pull_request:
branches: [ main ]
paths:
- terra-update-batch/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: production
steps:
- uses: actions/checkout@v3
- name: Azure Login
uses: Azure/login@v1.4.3
with:
client-id: ${{ secrets.AZ_CLIENT_ID }}
tenant-id: ${{ secrets.AZ_TENANT_ID }}
subscription-id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
- name: Publish 'Data Update' application
shell: pwsh
run: |
pushd terra-update-batch
Get-Content main.py | ?{ $_ -match '^# Version ([0-9]+)\.([0-9]+)\.([0-9\.]*)$' }
if ($Env:USE_RUN_NUMBER_AS_VERSION -eq "1") {
$Version = "$($matches[1]).$($matches[2]).${{ github.run_number }}"
} else {
$Version = "$($matches[1]).$($matches[2]).$($matches[3])"
}
$Pkg = "terraDataUpdate_$Version.zip"
Compress-Archive -Update -Path *.py, modules, resources, execute, run.sh, requirements.txt -DestinationPath $Pkg
dir $Pkg | ft Name,Length,LastWriteTime
az batch application package create `
--name $Env:BATCH_ACCOUNT_NAME `
--resource-group $Env:BATCH_ACCOUNT_RG `
--application-name $Env:BATCH_APP_PACKAGE_NAME_DATA_UPDATE `
--version-name $Version `
--package-file $Pkg
if ($Env:BATCH_APP_PACKAGE_NAME_DATA_UPDATE_SET_DEFAULT -eq 1) {
az batch application set `
--name $Env:BATCH_ACCOUNT_NAME `
--resource-group $Env:BATCH_ACCOUNT_RG `
--application-name $Env:BATCH_APP_PACKAGE_NAME_DATA_UPDATE `
--default-version $Version
echo "** Version $Version set as DEFAULT VERSION for package $Env:BATCH_APP_PACKAGE_NAME_DATA_UPDATE **"
}
popd
- name: Publish 'Prepare Node' application
if: ${{ env.PUBLISH_PREPARE_NODE == '1' }}
shell: pwsh
run: |
pushd terra-update-batch
Get-Content prepare-node.sh | ?{ $_ -match '^# Version ([0-9]+)\.([0-9]+)\.([0-9\.]*)$' }
if ($Env:USE_RUN_NUMBER_AS_VERSION -eq "1") {
$Version = "$($matches[1]).$($matches[2]).${{ github.run_number }}"
} else {
$Version = "$($matches[1]).$($matches[2]).$($matches[3])"
}
$Pkg = "prepare-node_$Version.zip"
Compress-Archive -Update -Path prepare-node.sh -DestinationPath $Pkg
dir $Pkg | ft Name,Length,LastWriteTime
az batch application package create `
--name $Env:BATCH_ACCOUNT_NAME `
--resource-group $Env:BATCH_ACCOUNT_RG `
--application-name $Env:BATCH_APP_PACKAGE_NAME_PREPARE_NODE `
--version-name $Version `
--package-file $Pkg
if ($Env:BATCH_APP_PACKAGE_NAME_PREPARE_NODE_SET_DEFAULT -eq 1) {
az batch application set `
--name $Env:BATCH_ACCOUNT_NAME `
--resource-group $Env:BATCH_ACCOUNT_RG `
--application-name $Env:BATCH_APP_PACKAGE_NAME_PREPARE_NODE `
--default-version $Version
echo "** Version $Version set as DEFAULT VERSION for package $Env:BATCH_APP_PACKAGE_NAME_PREPARE_NODE **"
}
popd