Skip to content
Open

Ci #5

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches: [ "main" ]

jobs:
build:
name: CI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0

- name: Build with dotnet
run: dotnet build --configuration Release

- name: dotnet publish
run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts
Comment on lines +9 to +24

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

The best way to fix this issue is to add a permissions: block at the appropriate level to limit the default permissions of the workflow. In this case, since the workflow is a typical CI job that checks out code and builds it—without performing writing operations to the repository or interacting with pull requests—the minimal necessary permission is contents: read. This can be set at the root of the workflow file (immediately after the name: and before on:) to apply to all jobs unless any require a different set. No other modifications, imports, or additional definitions are needed.

Specifically, insert the following at line 2:

permissions:
  contents: read
Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,4 +1,6 @@
 name: CI
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: CI
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
6 changes: 6 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ jobs:

- name: Build with dotnet
run: dotnet build --configuration Release

- name: dotnet test
run: dotnet test --configuration Release --no-build

- name: dotnet format
run: dotnet format -v detailed --verify-no-changes
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public void TemperatureFShouldReturnCorrectValueBasedOnTemperatureC()
};

weatherForecast.TemperatureF.Should().Be(32);
weatherForecast.TemperatureF.Should().Be(32);
}
}
2 changes: 2 additions & 0 deletions src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ public record WeatherForecast

public string? Summary { get; init; }
}