forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (52 loc) · 1.7 KB
/
sync-generation-to-future.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
name: sync-generation
run-name: Sync commit from generation to future - temporary
env:
GH_TOKEN: ${{ github.token }}
on:
push:
branches:
- 'generation'
jobs:
sync_generation:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-node@v4
with:
node-version: 14.17.1
- run: npm install -g autorest@latest
- uses: actions/checkout@v4
with:
ref: 'future'
- name: sync generation
shell: pwsh
run: |
Install-Module -Name PowerShellGet -RequiredVersion 2.2.3 -Force;
Install-Module -Name platyPS -RequiredVersion 0.14.2 -Force;
git config user.email "65331932+azure-powershell-bot@users.noreply.github.com";
git config user.name "azure-powershell-bot";
$commitId = '${{ github.sha }}'
$repoRoot = '${{ github.workspace }}'
git fetch origin generation
git cherry-pick $commitId --strategy-option theirs
git reset HEAD~1
<#
calculate changed modules
#>
$modulePaths = @()
git status --short | Where-Object { $_ -match ".*src.*" } | ForEach-Object { $modulePaths += $_.substring($_.IndexOf("src"), $_.IndexOf(".Autorest")+6) }
if (0 -eq $modulePaths.Count) {
return
}
$modulePaths = $modulePaths | Select-Object -Unique
foreach ($modulePath in $modulePaths) {
$modulePath = Join-Path $repoRoot $modulePath
Set-Location $modulePath
autorest --max-memory-size=8192
./build-module.ps1
}
Set-Location $repoRoot
git add src
git commit -m "cherry-pick $commitId from generation"
git push origin future