-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[StepSecurity] ci: Harden GitHub Actions (#145)
Signed-off-by: StepSecurity Bot <[email protected]>
- Loading branch information
1 parent
f3ef6d1
commit 4aa736b
Showing
4 changed files
with
38 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ on: | |
- 'example/**' | ||
- '.github/workflows/**' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
|
||
check-code-formatting: | ||
|
@@ -18,12 +21,12 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0 | ||
with: | ||
dotnet-version: '9.0.x' | ||
|
||
|
@@ -41,12 +44,12 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET SDK | ||
uses: actions/setup-dotnet@v4 | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0 | ||
with: | ||
dotnet-version: '9.0.x' | ||
|
||
|
@@ -59,35 +62,38 @@ jobs: | |
test: | ||
# This job is adapted from https://josh-ops.com/posts/github-code-coverage/ | ||
# It adds a code coverage report to all PR builds | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
name: Run all tests and generate PR-level code coverage report | ||
|
||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET SDK | ||
uses: actions/setup-dotnet@v4 | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0 | ||
with: | ||
dotnet-version: '9.0.x' | ||
|
||
- name: Run all tests | ||
run: dotnet test OwaspHeaders.Core.sln --verbosity minimal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage | ||
|
||
- name: Code Coverage Summary Report | ||
uses: irongut/[email protected] | ||
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 | ||
with: | ||
filename: 'coverage/*/coverage.cobertura.xml' | ||
badge: true | ||
format: 'markdown' | ||
output: 'both' | ||
|
||
- name: Add Coverage PR Comment | ||
uses: marocchino/[email protected] | ||
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
recreate: true | ||
|
@@ -103,19 +109,19 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET SDK | ||
uses: actions/setup-dotnet@v4 | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0 | ||
with: | ||
dotnet-version: '9.0.x' | ||
|
||
- name: Build NuGet Package | ||
run: dotnet pack src/OwaspHeaders.Core.csproj --configuration Release | ||
|
||
- uses: actions/upload-artifact@v4 | ||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | ||
if: ${{ success() }} | ||
with: | ||
name: OwaspHeaders.Core | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters