Skip to content

Commit afc22b7

Browse files
committed
Don't run generator if most recent pusher in PR is the generator itself
1 parent 42be0cc commit afc22b7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.github/workflows/generate-types-pr.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,28 @@ jobs:
1818
fetch-depth: 0
1919
ref: ${{ github.head_ref }}
2020

21+
- name: Check last commit author
22+
id: last-commit
23+
run: |
24+
AUTHOR=$(git log -1 --pretty=format:'%an')
25+
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
26+
2127
- name: Setup .NET 9
28+
if: steps.last-commit.outputs.author != 'github-actions[bot]'
2229
uses: actions/setup-dotnet@v4
2330
with:
2431
dotnet-version: '9.0.x'
2532

2633
- name: Restore dependencies
34+
if: steps.last-commit.outputs.author != 'github-actions[bot]'
2735
run: dotnet restore
2836

2937
- name: Run generator
38+
if: steps.last-commit.outputs.author != 'github-actions[bot]'
3039
run: dotnet run --project Generator/System.Management.Generator.csproj
3140

3241
- name: Check for changes
42+
if: steps.last-commit.outputs.author != 'github-actions[bot]'
3343
id: git-check
3444
run: |
3545
git config --global user.name "github-actions[bot]"
@@ -42,7 +52,7 @@ jobs:
4252
fi
4353
4454
- name: Commit and push changes to PR branch
45-
if: steps.git-check.outputs.no_changes == 'false'
55+
if: steps.last-commit.outputs.author != 'github-actions[bot]' && steps.git-check.outputs.no_changes == 'false'
4656
run: |
4757
git commit -m "chore(types): update generated types (PR auto-update)"
4858
git push

Generator/DefinitionLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ private static async Task<List<MethodDefinition>> ParseMethods(Uri classUri, str
365365
var tBodyIndex = methodBlock.IndexOf("<tbody");
366366
foreach (Match methodRow in TableRowRegex.Matches(methodBlock[tBodyIndex..]))
367367
{
368-
List<string> cells = [..TableCellRegex.Matches(methodRow.Groups[1].Value).Select(c => c.Groups[1].Value)];
368+
List<string> cells = [.. TableCellRegex.Matches(methodRow.Groups[1].Value).Select(c => c.Groups[1].Value)];
369369
if (cells.Count != 2)
370370
{
371371
ErrorReporter.Report($"Found unexpected number({cells.Count}) of cells in method Row.");

0 commit comments

Comments
 (0)