-
Notifications
You must be signed in to change notification settings - Fork 933
81 lines (68 loc) · 2.11 KB
/
Copy pathGenerateAsyncCode.yml
File metadata and controls
81 lines (68 loc) · 2.11 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: Generate Async code
on:
pull_request_target:
paths:
- '**.cs'
permissions:
contents: read
jobs:
generate-async:
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check_changes.outputs.has_changes }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Generate Async code
run: |
pushd src
dotnet tool restore
dotnet restore ./NHibernate.sln
dotnet async-generator
popd
- name: Check for changes
id: check_changes
run: |
git add -A
if git diff --cached --quiet -- '*.cs'; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
git diff --cached -- '*.cs' > changes.patch
fi
- name: Upload patch
if: steps.check_changes.outputs.has_changes == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: async-changes
path: changes.patch
retention-days: 1
commit-changes:
needs: generate-async
if: needs.generate-async.outputs.has_changes == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Download patch
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: async-changes
- name: Apply patch
run: git apply changes.patch
- name: Commit and push
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "Generate async files"
file_pattern: "**/*.cs"