-
Notifications
You must be signed in to change notification settings - Fork 518
/
azure-pipelines-autogen.yml
90 lines (77 loc) · 2.38 KB
/
azure-pipelines-autogen.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
pr: none
trigger: none
schedules:
- cron: "0 8 * * *"
branches:
include:
- autogenerate
displayName: Daily autogeneration
jobs:
- job: Autogenerate
timeoutInMinutes: 360
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
clean: true
- task: DownloadSecureFile@1
name: schemasDeployKey
inputs:
secureFile: schemas_rsa
displayName: "Download GitHub Deploy Key"
- task: NodeTool@0
inputs:
versionSpec: '14.x'
- script: |
set -Eeuxo pipefail
mkdir ~/.ssh && mv $(schemasDeployKey.secureFilePath) ~/.ssh/schemas_rsa
chmod 700 ~/.ssh
chmod 600 ~/.ssh/schemas_rsa
git config user.name "Autogenerator Pipeline"
git config user.email "[email protected]"
git config core.sshCommand "ssh -i ~/.ssh/schemas_rsa -F /dev/null"
git remote set-url origin [email protected]:Azure/azure-resource-manager-schemas.git
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
git fetch
displayName: Configure git
- script: |
set -Eeuxo pipefail
git checkout $(Build.SourceBranchName)
git pull
git merge --no-commit --no-ff --strategy-option=theirs origin/main
if ! git diff-index --quiet HEAD --; then
git commit -m "Merge remote-tracking branch 'origin/main' into $(Build.SourceBranchName)"
git push origin $(Build.SourceBranchName)
fi
displayName: Integrate main branch
- script: |
set -Eeuxo pipefail
cd generator
npm ci
displayName: 'Install packages'
- script: |
set -Eeuxo pipefail
cd generator
npm run generate-all -- --batch-count $(batchCount) --batch-index $(batchIndex)
displayName: 'Generate schemas'
- script: |
set -Eeuxo pipefail
git add --all schemas
if ! git diff-index --quiet HEAD --; then
git commit -m "Autogenerate schemas"
git push origin $(Build.SourceBranchName)
fi
displayName: Commit autogenerated schemas
- script: |
set -Eeuxo pipefail
cd generator
npm run list-resources resources.json
displayName: 'List resources'
- script: |
set -Eeuxo pipefail
git add generator/resources.json
if ! git diff-index --quiet HEAD --; then
git commit -m "Update resource list"
git push origin $(Build.SourceBranchName)
fi
displayName: Commit resource list