-
Notifications
You must be signed in to change notification settings - Fork 190
67 lines (61 loc) · 2.28 KB
/
update-cache.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
name: update-cache
#on: workflow_dispatch
on:
schedule:
- cron: '55 11 7,21 * *'
jobs:
UpdateTTKCache:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Log in with Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: Update TTK Cache
uses: Azure/powershell@v1
with:
errorActionPreference: Continue
inlineScript: |
Get-ChildItem -Recurse -Filter arm-ttk.psd1 | Import-Module -Name { $_.FullName} -Force -PassThru | Out-String
Update-TTKCache
$updatedFiles = 0
$branchName = "CacheUpdate-$([DateTime]::Now.ToString("yyyy-MM-dd"))"
git config --global user.email [email protected]
git config --global user.name Azure
git checkout -b $branchName
git pull origin master
Get-ChildItem -Recurse -Filter *.cache.json |
ForEach-Object {
$inFile = $_
if (git diff $inFile.FullName) {
git add $inFile.FullName
git commit -m "Updating $($inFile.Name)"
$updatedFiles+=2
}
}
if ($updatedFiles) {
$gitPushed = git push --set-upstream origin $branchName 2>&1
"Git Push Output: $($gitPushed | Out-String)"
$d = @{
head = $branchName
base = "master"
title = $branchName
}
$params = @{
Uri = 'https://api.github.com/repos/Azure/arm-ttk/pulls';
Method = 'POST';
Headers = @{
Accept = "application/vnd.github.v3+json"
Authorization = "Bearer ${{ secrets.GITHUB_TOKEN }}"
}
Body = (ConvertTo-Json $d -Compress)
}
Invoke-RestMethod @params
$LASTEXITCODE = 0
exit 0
}
exit 0
azPSVersion: 3.1.0