Skip to content

Commit 2574552

Browse files
committed
ci: use two-stage format push
1 parent 89eacbc commit 2574552

File tree

4 files changed

+60
-55
lines changed

4 files changed

+60
-55
lines changed

.github/workflows/codeql.yml

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,40 @@ on:
66
pull_request:
77
branches: [main]
88
schedule:
9-
- cron: '24 23 * * 0'
9+
- cron: "24 23 * * 0"
1010

1111
env:
1212
NUGET_PACKAGES: ${{ github.workspace }}\.nuget\packages
1313

1414
permissions:
1515
security-events: write
16-
actions: read
17-
contents: read
1816

1917
jobs:
2018
analyze:
2119
runs-on: windows-latest
2220

2321
steps:
24-
- name: Checkout repository
25-
uses: actions/checkout@v6.0.2
26-
with:
27-
show-progress: false
28-
29-
- name: Initialise CodeQL
30-
uses: github/codeql-action/init@v4.32.6
31-
with:
32-
languages: csharp
33-
34-
- name: Setup .NET
35-
uses: actions/setup-dotnet@v5.2.0
36-
with:
37-
dotnet-version: 9.x
38-
cache: true
39-
cache-dependency-path: lc-hax\packages.lock.json
40-
41-
- name: Build
42-
run: dotnet build lc-hax -restoreProperty:RestoreLockedMode=true
43-
44-
- name: Perform CodeQL Analysis
45-
uses: github/codeql-action/analyze@v4.32.6
46-
with:
47-
category: /language:csharp
22+
- name: Checkout repository
23+
uses: actions/checkout@v6.0.2
24+
with:
25+
show-progress: false
26+
27+
- name: Initialise CodeQL
28+
uses: github/codeql-action/init@v4.32.6
29+
with:
30+
languages: csharp
31+
32+
- name: Setup .NET
33+
uses: actions/setup-dotnet@v5.2.0
34+
with:
35+
dotnet-version: 10.x
36+
cache-dependency-path: lc-hax\packages.lock.json
37+
cache: true
38+
39+
- name: Build
40+
run: dotnet build lc-hax -restoreProperty:RestoreLockedMode=true
41+
42+
- name: Perform CodeQL Analysis
43+
uses: github/codeql-action/analyze@v4.32.6
44+
with:
45+
category: /language:csharp

.github/workflows/formatter.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,40 @@ on:
99
- lc-hax/Scripts/**/*.cs
1010

1111
concurrency: ${{ github.workflow }}-${{ github.ref }}
12-
permissions:
13-
contents: write
12+
permissions: {}
1413

1514
jobs:
1615
format:
1716
runs-on: ubuntu-slim
17+
outputs:
18+
patched: ${{ steps.patch.outputs.patched }}
1819

1920
steps:
2021
- name: Checkout repository
2122
uses: actions/checkout@v6.0.2
2223
with:
2324
show-progress: false
25+
persist-credentials: false
2426
repository: ${{ github.event.pull_request.head.repo.full_name }}
2527
ref: ${{ github.head_ref }}
2628

2729
- name: Setup .NET
2830
uses: actions/setup-dotnet@v5.2.0
2931
with:
30-
dotnet-version: 9.x
32+
dotnet-version: 10.x
3133

3234
- name: Format scripts
3335
run: |
3436
dotnet format lc-hax
3537
dotnet format analysers
3638
37-
- name: Set Git config
38-
run: |
39-
git config user.email github-actions[bot]@users.noreply.github.com
40-
git config user.name github-actions[bot]
39+
- name: Upload format patch
40+
id: patch
41+
uses: winstxnhdw/actions/upload-patch@main
4142

42-
- name: Commit changes
43-
run: |
44-
git commit -am "style: format scripts" || true
45-
git pull --rebase origin ${{ github.head_ref || github.ref_name }}
46-
git push origin HEAD:$BRANCH
43+
push:
44+
if: needs.format.outputs.patched
45+
needs: format
46+
uses: winstxnhdw/actions/.github/workflows/format-push.yml@main
47+
permissions:
48+
contents: write

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
uses: actions/setup-dotnet@v5.2.0
2626
with:
2727
dotnet-version: 10.x
28-
cache: true
2928
cache-dependency-path: lc-hax\packages.lock.json
29+
cache: true
3030

3131
- name: Build
3232
run: dotnet build lc-hax -restoreProperty:RestoreLockedMode=true /warnaserror

.github/workflows/update-resource.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,25 @@ on:
88
- lc-hax/*.csproj
99

1010
concurrency: Format-Resource-${{ github.ref }}
11-
permissions:
12-
contents: write
11+
permissions: {}
12+
env:
13+
BRANCH: ${{ github.head_ref || github.ref_name }}
14+
PATCH_NAME: format.patch
15+
ARTIFACT_NAME: format-patch
1316

1417
jobs:
15-
update-resource:
16-
runs-on: ubuntu-latest
18+
update:
19+
runs-on: ubuntu-slim
20+
outputs:
21+
patched: ${{ steps.patch.outputs.patched }}
1722

1823
steps:
1924
- name: Checkout repository
2025
uses: actions/checkout@v6.0.2
2126
with:
2227
show-progress: false
28+
persist-credentials: false
2329
ref: ${{ github.head_ref }}
24-
token: ${{ secrets.PAT }}
2530

2631
- name: Cache .NET tools
2732
uses: actions/cache@v5.0.3
@@ -33,7 +38,7 @@ jobs:
3338
- name: Setup .NET
3439
uses: actions/setup-dotnet@v5.2.0
3540
with:
36-
dotnet-version: 9.x
41+
dotnet-version: 10.x
3742

3843
- name: Restore tools
3944
run: dotnet tool restore
@@ -43,13 +48,13 @@ jobs:
4348
env:
4449
CSPROJ_PATH: lc-hax/lc-hax.csproj
4550

46-
- name: Set Git config
47-
run: |
48-
git config user.email github-actions[bot]@users.noreply.github.com
49-
git config user.name github-actions[bot]
51+
- name: Upload format patch
52+
id: patch
53+
uses: winstxnhdw/actions/upload-patch@main
5054

51-
- name: Commit changes
52-
run: |
53-
git commit -am "build: update resource path(s)" || true
54-
git pull --rebase origin ${{ github.head_ref || github.ref_name }}
55-
git push
55+
push:
56+
if: needs.update.outputs.patched
57+
needs: update
58+
uses: winstxnhdw/actions/.github/workflows/format-push.yml@main
59+
permissions:
60+
contents: write

0 commit comments

Comments
 (0)