Skip to content

Commit e37305f

Browse files
committed
use on-push
1 parent f4b81bb commit e37305f

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'NuGet Lockfile Sync'
2+
description: 'Force restore and commit updated NuGet lock files for Dependabot NuGet PRs'
3+
inputs:
4+
dotnet-version:
5+
description: 'Dotnet SDK version'
6+
required: false
7+
default: '9.0.304'
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- name: Setup .NET
13+
uses: actions/setup-dotnet@v4
14+
with:
15+
dotnet-version: ${{ inputs.dotnet-version }}
16+
17+
- name: Force restore
18+
shell: bash
19+
run: dotnet restore --force-evaluate
20+
21+
- name: Commit and Push Changes
22+
shell: bash
23+
run: |
24+
set -euo pipefail
25+
git config --global user.name 'dependabot[bot]'
26+
git config --global user.email '[email protected]'
27+
echo '*****STARTING LOCKFILE SYNC*****'
28+
git branch --show-current
29+
git status
30+
git add -A
31+
git commit -m 'Update lock files' || echo 'No changes to commit'
32+
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
33+
echo "The branch name is $BRANCH_NAME"
34+
git push origin "$BRANCH_NAME"

.github/workflows/build.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
auto-sync:
18-
name: Auto Sync Lock Files (Dependabot only)
19-
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' && startsWith(github.head_ref, 'dependabot/nuget/')
20-
uses: ./.github/workflows/nuget-lockfile-sync.yml
21-
2217
build:
2318
name: Build
2419
runs-on: ubuntu-latest
@@ -27,11 +22,14 @@ jobs:
2722
uses: actions/checkout@v4
2823
with:
2924
ref: ${{ github.head_ref || github.ref }}
25+
3026
- name: Setup .NET
3127
uses: actions/setup-dotnet@v4
3228
with:
3329
dotnet-version: 9.0.304
30+
3431
- name: Restore dependencies
3532
run: dotnet restore --locked-mode
33+
3634
- name: Build
3735
run: dotnet build --no-restore

.github/workflows/nuget-lockfile-sync.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
name: Auto Sync Lock Files
22

33
on:
4-
workflow_call:
5-
inputs:
6-
dotnet-version:
7-
description: 'Dotnet SDK version'
8-
required: false
9-
type: string
10-
default: '9.0.304'
11-
secrets: {}
4+
push:
5+
branches:
6+
- 'dependabot/nuget/**'
127

138
permissions:
149
actions: read
@@ -30,7 +25,7 @@ jobs:
3025
- name: Setup .NET
3126
uses: actions/setup-dotnet@v4
3227
with:
33-
dotnet-version: ${{ inputs.dotnet-version }}
28+
dotnet-version: 9.0.304
3429

3530
- name: Force restore
3631
run: dotnet restore --force-evaluate

0 commit comments

Comments
 (0)