Skip to content

Commit bf5e724

Browse files
committed
Updated CI so Copilot-created PRs can start without waiting for manual workflow approval
1 parent b734bfb commit bf5e724

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
name: Build with Tests
22

3-
on:
4-
push:
5-
workflow_dispatch:
6-
pull_request:
7-
types: [opened, edited]
3+
on:
4+
push:
5+
workflow_dispatch:
6+
pull_request:
7+
types: [opened, synchronize, reopened, edited]
8+
pull_request_target:
9+
types: [opened, synchronize, reopened, edited]
10+
11+
permissions:
12+
contents: read
813

914
jobs:
1015
build_and_test_Windows:
1116
name: "Windows: Build and Tests"
17+
if: ${{ github.event_name != 'pull_request_target' || startsWith(github.actor, 'copilot') || github.actor == 'github-copilot[bot]' }}
1218
runs-on: windows-latest
1319

1420
env:
1521
IsRunningOnGitHubActions: 'true'
1622
UseInMemory: 'true'
1723

18-
steps:
24+
steps:
1925
- uses: actions/checkout@v4
2026
with:
2127
fetch-depth: 0
28+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
29+
persist-credentials: false
2230

2331
- uses: actions/setup-dotnet@v4
2432
with:
2533
dotnet-version: '10.0.x'
26-
34+
2735
- name: Build
2836
run: |
2937
dotnet build ./src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj -c Release -p:buildType=azure-pipelines-ci
@@ -34,15 +42,19 @@ jobs:
3442
3543
build_and_test_Linux:
3644
name: "Linux: Build and Tests"
45+
if: ${{ github.event_name != 'pull_request_target' || startsWith(github.actor, 'copilot') || github.actor == 'github-copilot[bot]' }}
3746
runs-on: ubuntu-latest
3847

3948
env:
4049
IsRunningOnGitHubActions: 'true'
4150
BranchName: ${{ github.head_ref || github.ref_name }}
4251

43-
steps:
52+
steps:
4453
- uses: actions/checkout@v4
45-
54+
with:
55+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
56+
persist-credentials: false
57+
4658
- uses: actions/setup-dotnet@v4
4759
with:
4860
dotnet-version: '9.0.x'
@@ -58,6 +70,7 @@ jobs:
5870
dotnet tool install --global dotnet-coverage
5971
6072
- name: Check if analysis on SonarCloud is possible
73+
if: ${{ github.event_name != 'pull_request_target' }}
6174
id: secret-check
6275
# perform secret check & put boolean result as an output
6376
shell: bash
@@ -69,31 +82,31 @@ jobs:
6982
fi
7083
7184
- name: Begin analysis on SonarCloud
72-
if: ${{ steps.secret-check.outputs.run_analysis == 'true' }}
85+
if: ${{ github.event_name != 'pull_request_target' && steps.secret-check.outputs.run_analysis == 'true' }}
7386
run: |
7487
dotnet sonarscanner begin /k:"zzzprojects_System.Linq.Dynamic.Core" /o:"zzzprojects" /d:sonar.branch.name=$BranchName /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token=${{ secrets.SONAR_TOKEN }} /d:sonar.pullrequest.provider=github /d:sonar.dotnet.excludeTestProjects=true /d:sonar.cs.vscoveragexml.reportsPaths=**/dynamic-coverage-*.xml /d:sonar.verbose=true
75-
88+
7689
- name: Build
7790
run: |
7891
dotnet build ./src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj -c Debug -p:buildType=azure-pipelines-ci
79-
92+
8093
- name: Run Tests EFCore .NET 10 (with Coverage)
8194
run: |
8295
dotnet-coverage collect 'dotnet test ./test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj --configuration Debug -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-efcore.xml
83-
96+
8497
- name: Run Tests EF .NET 10 (with Coverage)
8598
run: |
8699
dotnet-coverage collect 'dotnet test ./test/EntityFramework.DynamicLinq.Tests/EntityFramework.DynamicLinq.Tests.csproj --configuration Debug --framework net10.0 -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-ef.xml
87-
100+
88101
- name: Run Tests Newtonsoft.Json .NET 10 (with Coverage)
89102
run: |
90103
dotnet-coverage collect 'dotnet test ./test/System.Linq.Dynamic.Core.NewtonsoftJson.Tests/System.Linq.Dynamic.Core.NewtonsoftJson.Tests.csproj --configuration Debug --framework net10.0 -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-newtonsoftjson.xml
91-
104+
92105
- name: Run Tests System.Text.Json .NET 10 (with Coverage)
93106
run: |
94107
dotnet-coverage collect 'dotnet test ./test/System.Linq.Dynamic.Core.SystemTextJson.Tests/System.Linq.Dynamic.Core.SystemTextJson.Tests.csproj --configuration Debug --framework net10.0 -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-systemtextjson.xml
95108
96109
- name: End analysis on SonarCloud
97-
if: ${{ steps.secret-check.outputs.run_analysis == 'true' }}
110+
if: ${{ github.event_name != 'pull_request_target' && steps.secret-check.outputs.run_analysis == 'true' }}
98111
run: |
99112
dotnet sonarscanner end /d:sonar.token=${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)