Skip to content

Commit 78da45e

Browse files
authored
Add explicit permissions to all GHA workflows (#630)
*Issue #, if available:* N/A *Description of changes:* Adding explicit permissions to adopt least-privilege principle in workflows. Some permissions were no longer used: for example, we no longer publish the test coverage although we still tried to write it to the job summary. This removes that for now. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
1 parent c654435 commit 78da45e

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/build_matrix.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
matrix:
55
description: "Matrix"
66
value: ${{ jobs.build_matrix.outputs.matrix }}
7+
8+
permissions:
9+
contents: read
10+
711
jobs:
812
build_matrix:
913
runs-on: ubuntu-latest

.github/workflows/controller-tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
merge_group:
99
types: ["checks_requested"]
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build_matrix:
1316
name: Build Matrix

.github/workflows/notify-slack.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
pull_request_target:
77
types: [opened, reopened, synchronize]
88

9+
permissions: {}
10+
911
jobs:
1012
notify:
1113
runs-on: ubuntu-latest
@@ -32,4 +34,4 @@ jobs:
3234
{
3335
"action": "${{ github.event.action }}",
3436
"url": "${{ github.event.pull_request.html_url }}"
35-
}
37+
}

.github/workflows/release.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
environment: release
1414
runs-on: ubuntu-latest
1515
permissions:
16-
id-token: write
1716
contents: write
1817
steps:
1918
- name: Create Release
@@ -34,6 +33,8 @@ jobs:
3433
helm:
3534
needs: build
3635
runs-on: ubuntu-latest
36+
permissions:
37+
contents: write
3738
steps:
3839
- name: Checkout
3940
uses: actions/checkout@v5

.github/workflows/unit-tests.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
merge_group:
99
types: [ "checks_requested" ]
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build:
1316
runs-on: ubuntu-latest
@@ -47,11 +50,9 @@ jobs:
4750
name: cover
4851
path: cover.html
4952

50-
- name: Comment test coverage
53+
- name: Post test coverage to step summary
5154
if: ${{ github.event_name == 'pull_request' }}
5255
env:
53-
TOTAL_COVERAGE: ${{ steps.go-test-coverage.outputs.total-coverage }}
5456
ARTIFACT_URL: ${{ steps.uploaded-report.outputs.artifact-url }}
5557
run: |
56-
echo "### Total test coverage: ${{ env.TOTAL_COVERAGE }}%" >> $GITHUB_STEP_SUMMARY
57-
echo "Download report: ${{ env.ARTIFACT_URL }}" >> $GITHUB_STEP_SUMMARY
58+
echo "Test coverage report: ${{ env.ARTIFACT_URL }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)