-
Notifications
You must be signed in to change notification settings - Fork 0
Added generator actions to keep the generated files fresh. #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
44a06ac
Added generator actions to keep the generated files fresh.
Triogap 42be0cc
Don't run build when generator needs to run during PR
Triogap afc22b7
Don't run generator if most recent pusher in PR is the generator itself
Triogap a82c650
Don't parse methods for now logic is not yet fully formed.
Triogap 38df064
Adjust workflows based on pr issues
Triogap 2e452d0
Fix generator exception
Triogap 460ab58
Update .gitignore to not ignore Types/Win32
Triogap 4a9a77d
Updated getting targetDirectory in generator
Triogap a08d640
Updated generator workflows to be able to push
Triogap 56ee0ce
chore(types): update generated types (PR auto-update)
github-actions[bot] 52e10b6
Correct file trigger on pr-generator.yml
Triogap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,51 @@ | ||
| name: Weekly Type Generation and Auto PR | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 3 * * 1' # Every Monday at 03:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| generate-and-pr: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup .NET 9 | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Run generator | ||
| run: dotnet run --project Generator/System.Management.Generator.csproj | ||
|
|
||
| - name: Check for changes | ||
| id: git-check | ||
| run: | | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add Types/**/*.g.cs | ||
| if git diff --cached --quiet; then | ||
| echo "no_changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "no_changes=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Create Pull Request | ||
| if: steps.git-check.outputs.no_changes == 'false' | ||
| uses: peter-evans/create-pull-request@v6 | ||
| with: | ||
| commit-message: "chore(types): update generated types" | ||
| branch: "auto/generated-types-update" | ||
| title: "chore(types): update generated types" | ||
| body: | | ||
| Automated update of generated types from learn.microsoft.com. | ||
| This PR was created by a scheduled GitHub Action. | ||
| delete-branch: true |
This file contains hidden or 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,58 @@ | ||
| name: PR Type Generation | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'Generator/*.*' | ||
| - 'Types/**/*.g.cs' | ||
| - '.github/workflows/generate-types-pr.yml' | ||
|
|
||
| jobs: | ||
| generate-and-commit: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.head_ref }} | ||
|
|
||
| - name: Check last commit author | ||
| id: last-commit | ||
| run: | | ||
| AUTHOR=$(git log -1 --pretty=format:'%an') | ||
| echo "author=$AUTHOR" >> $GITHUB_OUTPUT | ||
| - name: Setup .NET 9 | ||
| if: steps.last-commit.outputs.author != 'github-actions[bot]' | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| if: steps.last-commit.outputs.author != 'github-actions[bot]' | ||
| run: dotnet restore | ||
|
|
||
| - name: Run generator | ||
| if: steps.last-commit.outputs.author != 'github-actions[bot]' | ||
| run: dotnet run --project Generator/System.Management.Generator.csproj | ||
|
|
||
| - name: Check for changes | ||
| if: steps.last-commit.outputs.author != 'github-actions[bot]' | ||
Triogap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id: git-check | ||
| run: | | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add Types/**/*.g.cs | ||
| if git diff --cached --quiet; then | ||
| echo "no_changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "no_changes=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Commit and push changes to PR branch | ||
| if: steps.last-commit.outputs.author != 'github-actions[bot]' && steps.git-check.outputs.no_changes == 'false' | ||
| run: | | ||
| git commit -m "chore(types): update generated types (PR auto-update)" | ||
| git push | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.