sync-crds #20799
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
name: sync-crds | |
on: | |
push: | |
branches: | |
- alpha | |
workflow_dispatch: | |
schedule: | |
- cron: "0 * * * *" | |
jobs: | |
sync-crds: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
- uses: azure/setup-helm@v4 | |
with: | |
version: 'latest' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Remove Models from Solution | |
run: dotnet sln remove ./src/Models/**/*.csproj | |
- name: Clean Models | |
run: rm -rf ./src/Models/KubernetesCRDModelGen* | |
- name: Sync CRDs | |
run: dotnet run --project ./src/KubernetesCRDModelGen.Sync/KubernetesCRDModelGen.Sync.csproj --ModelDir ../Models | |
- name: Add Models to Solution | |
run: dotnet sln add ./src/Models/**/*.csproj | |
- name: Build Model packages | |
shell: pwsh | |
run: | | |
$projects = Get-ChildItem -Path $PWD\src\Models -Recurse -Filter *.csproj | |
foreach($project in $projects){ | |
dotnet run --project src\KubernetesCRDModelGen.Tool\KubernetesCRDModelGen.Tool.csproj --FolderPath $($project.Directory) | |
if (-not $?) { | |
throw "CRD Generation Failed" | |
} | |
} | |
- name: Validate Yamls | |
working-directory: src/Models | |
shell: pwsh | |
run: | | |
foreach ($Dir in Get-ChildItem -Directory) { | |
$YamlFiles = Get-ChildItem -Path $Dir.FullName -Filter *.yaml -File -ErrorAction SilentlyContinue | |
if ($YamlFiles.Count -eq 0) { | |
throw "No .yaml file found in directory: $($Dir.FullName)" | |
} | |
} | |
- name: Validate Models | |
working-directory: src/Models | |
shell: pwsh | |
run: | | |
foreach ($Dir in Get-ChildItem -Directory) { | |
$CSFiles = Get-ChildItem -Path $Dir.FullName -Filter *.g.cs -File -ErrorAction SilentlyContinue | |
if ($CSFiles.Count -eq 0) { | |
throw "No .g.cs file found in directory: $($Dir.FullName)" | |
} | |
} | |
- name: Check Files Changed | |
id: checkfiles | |
shell: pwsh | |
run: | | |
git add . | |
$createPR = (git diff --cached --numstat | Measure-Object -Line).Lines -gt 1; | |
echo "createpr=$createPR" >> $env:GITHUB_OUTPUT | |
- name: Create Pull Request | |
if: steps.checkfiles.outputs.createpr == 'True' | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GHPAT }} | |
branch: sync-charts | |
commit-message: "feat: Update CRDs" | |
title: "feat: Update CRDs" | |
body: "Automated CRD Sync" | |
- name: Enable Pull Request Automerge | |
if: steps.checkfiles.outputs.createpr == 'True' | |
run: gh pr merge --merge --auto "${{ steps.cpr.outputs.pull-request-number }}" | |
env: | |
GH_TOKEN: ${{ secrets.GHPAT }} |