Skip to content

Commit 5f7ed32

Browse files
authored
ci: Updated workflows to include permissions. (#4)
1 parent d624a7c commit 5f7ed32

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

.github/workflows/branch.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches-ignore:
66
- main
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
lint:
1013
name: Lint updated files
@@ -24,23 +27,23 @@ jobs:
2427
- name: Init TFLint
2528
run: tflint --init
2629
- name: Run TFLint
27-
run: tflint --format compact --recursive --config "$GITHUB_WORKSPACE/.tflint.hcl"
30+
run: tflint --format compact --recursive
2831

2932
trivy:
3033
name: Run security scan
3134
runs-on: ubuntu-latest
3235
steps:
3336
- name: Checkout source code
3437
uses: actions/checkout@v4
35-
- name: Run Trivy vulnarability scanner
36-
uses: aquasecurity/trivy-action@master
38+
- name: Run Trivy vulnerability scanner
39+
uses: aquasecurity/trivy-action@0.30.0
3740
with:
3841
scan-type: config
3942
format: sarif
40-
output: "trivy-results.sarif"
43+
output: trivy-results.sarif
4144
- name: Parse SARIF file
4245
# Always run this step, even if a previous step failed.
4346
if: always()
4447
uses: Ayrx/sarif_to_github_annotations@v0.2.2
4548
with:
46-
sarif_file: "trivy-results.sarif"
49+
sarif_file: trivy-results.sarif

.github/workflows/codeql-analysis.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ jobs:
2020
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
2121
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
2222
permissions:
23-
# required for all workflows
2423
security-events: write
25-
# required to fetch internal or private CodeQL packs
2624
packages: read
27-
# only required for workflows in private repositories
2825
actions: read
2926
contents: read
3027
strategy:

.github/workflows/main.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
security-events: write
11+
812
jobs:
913
lint:
1014
name: Lint updated modules
1115
runs-on: ubuntu-latest
16+
env:
17+
# Required to avoid rate limiting when downloading plugins.
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1219
steps:
1320
- name: Checkout source code
1421
uses: actions/checkout@v4
@@ -24,7 +31,12 @@ jobs:
2431
- name: Init TFLint
2532
run: tflint --init
2633
- name: Run TFLint
27-
run: tflint --format compact --recursive --config "$GITHUB_WORKSPACE/.tflint.hcl"
34+
run: tflint --format sarif --recursive --config "$GITHUB_WORKSPACE/.tflint.hcl" > tflint-results.sarif
35+
- name: Upload SARIF result
36+
if: always()
37+
uses: github/codeql-action/upload-sarif@v3
38+
with:
39+
sarif_file: tflint-results.sarif
2840

2941
trivy:
3042
name: Run security scan
@@ -33,14 +45,14 @@ jobs:
3345
- name: Checkout source code
3446
uses: actions/checkout@v4
3547
- name: Run Trivy vulnarability scanner
36-
uses: aquasecurity/trivy-action@master
48+
uses: aquasecurity/trivy-action@0.32.0
3749
with:
3850
scan-type: config
3951
format: sarif
40-
output: "trivy-results.sarif"
52+
output: trivy-results.sarif
4153
- name: Upload SARIF result
4254
# Always run this step, even if a previous step failed.
4355
if: always()
4456
uses: github/codeql-action/upload-sarif@v3
4557
with:
46-
sarif_file: "trivy-results.sarif"
58+
sarif_file: trivy-results.sarif

.github/workflows/release.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Release New Version
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- main
@@ -12,6 +13,9 @@ jobs:
1213
name: Build new release
1314
runs-on: ubuntu-latest
1415
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
16+
permissions:
17+
contents: write
18+
pull-requests: write
1519
steps:
1620
- name: Checkout source code
1721
uses: actions/checkout@v4
@@ -40,6 +44,8 @@ jobs:
4044
name: Release module
4145
runs-on: ubuntu-latest
4246
if: startsWith(github.event.head_commit.message, 'bump:')
47+
permissions:
48+
contents: write
4349
steps:
4450
- name: Checkout source code
4551
uses: actions/checkout@v4

0 commit comments

Comments
 (0)