Repository navigation
Expand file tree
/
Copy pathrun-codegen-pull-request-task.yml
More file actions
81 lines (70 loc) · 2.75 KB
/
Copy pathrun-codegen-pull-request-task.yml
File metadata and controls
81 lines (70 loc) · 2.75 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Run .NET codegen and pull request task
on:
workflow_call:
secrets:
CODEGEN_APP_CLIENT_ID:
required: true
CODEGEN_APP_PRIVATE_KEY:
required: true
jobs:
# No job-level permissions declared: every write here (the checkout, the pull request) uses the App token, so GITHUB_TOKEN needs no scope and the caller can grant permissions: {}.
codegen:
name: Run ${{ matrix.target.ref }} codegen and pull request job
runs-on: ubuntu-latest
strategy:
# Each branch gets its own parallel codegen run and PR.
# One branch's failure does not affect the other.
fail-fast: false
matrix:
target:
- ref: main
branch: codegen-main
- ref: develop
branch: codegen-develop
steps:
# App token so the PR open fires pull_request workflow events.
# A GITHUB_TOKEN open does not.
- name: Generate GitHub App token step
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ secrets.CODEGEN_APP_CLIENT_ID }}
private-key: ${{ secrets.CODEGEN_APP_PRIVATE_KEY }}
- name: Setup .NET SDK step
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: 10.x
- name: Checkout code step
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ matrix.target.ref }}
token: ${{ steps.app-token.outputs.token }}
- name: Run codegen hook step
if: ${{ hashFiles('.github/actions/codegen/action.yml') != '' }}
uses: ./.github/actions/codegen
- name: Missing codegen hook step
if: ${{ hashFiles('.github/actions/codegen/action.yml') == '' }}
run: |
set -Eeuo pipefail
echo "::error::Required hook missing: .github/actions/codegen/action.yml"
exit 1
- name: Format code step
run: |
set -Eeuo pipefail
dotnet tool restore
dotnet husky install
dotnet csharpier format --log-level=debug .
git status
# App token: fires pull_request workflow events and creates verified commits as the app.
- name: Create pull request step
id: cpr
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ steps.app-token.outputs.token }}
base: ${{ matrix.target.ref }}
branch: ${{ matrix.target.branch }}
title: 'Update codegen files'
body: 'This PR updates the codegen files.'
commit-message: 'Update codegen files'
delete-branch: true
sign-commits: true