-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github action to sync generation branch to future branch (#25019)
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 "[email protected]"; | ||
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 | 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 |