Skip to content

Commit 4774ea5

Browse files
kalleepjharvey10
andauthored
fix github actions (#3463)
* ci: resolve workflow template injection issues (#3460) * ci: adjust unpinned workflow comments * ci: remove extraneous workflow permissions from publish-alloy-devel * ci: add ignore/explanation for usage of pull_request_target * ci: add contents: read to all workflows without a permissions block --------- Co-authored-by: Joe Harvey <51208233+jharvey10@users.noreply.github.com>
1 parent 2bf33ed commit 4774ea5

33 files changed

+257
-41
lines changed

.github/workflows/backport.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Backport PR Creator
22
on:
3-
pull_request_target:
3+
pull_request_target: # zizmor: ignore[dangerous-triggers] In order to backport PRs from external
4+
# contributors, this workflow needs to run against the base repo. The checkout action below is
5+
# pinned to a specific commit to prevent arbitrary code execution by a fork that updates the
6+
# logic of this workflow.
47
types:
58
- closed
69
- labeled
710

11+
permissions:
12+
contents: read
13+
814
jobs:
915
main:
1016
runs-on: ubuntu-latest
@@ -14,9 +20,10 @@ jobs:
1420
with:
1521
repository: "grafana/grafana-github-actions"
1622
path: ./actions
17-
# Pin the version to before https://github.com/grafana/grafana-github-actions/pull/113 because
23+
# Pin the version to before https://github.com/grafana/grafana-github-actions/pull/113
1824
# to avoid the strict rules for PR labels.
1925
ref: d284afd314ca3625c23595e9f62b52d215ead7ce
26+
persist-credentials: false
2027
- name: Install Actions
2128
run: npm install --production --prefix ./actions
2229
- name: Run backport

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ concurrency:
77
# and head_ref (available when CI is triggered by a PR).
88
group: "${{ github.ref_name }}-${{ github.head_ref }}"
99
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read
13+
1014
jobs:
1115
build_linux:
1216
name: Build on Linux
@@ -19,6 +23,8 @@ jobs:
1923
steps:
2024
- name: Checkout code
2125
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
persist-credentials: false
2228
- name: Set ownership
2329
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
2430
run: |
@@ -44,6 +50,8 @@ jobs:
4450
steps:
4551
- name: Checkout code
4652
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
53+
with:
54+
persist-credentials: false
4755
- name: Set ownership
4856
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
4957
run: |
@@ -64,6 +72,8 @@ jobs:
6472
steps:
6573
- name: Checkout code
6674
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
75+
with:
76+
persist-credentials: false
6777
- name: Set up Go
6878
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
6979
with:
@@ -79,6 +89,8 @@ jobs:
7989
steps:
8090
- name: Checkout code
8191
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
92+
with:
93+
persist-credentials: false
8294
- name: Set up Go
8395
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
8496
with:
@@ -94,6 +106,8 @@ jobs:
94106
steps:
95107
- name: Checkout code
96108
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
109+
with:
110+
persist-credentials: false
97111
- name: Set up Go
98112
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
99113
with:
@@ -113,6 +127,8 @@ jobs:
113127
steps:
114128
- name: Checkout code
115129
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
130+
with:
131+
persist-credentials: false
116132
- name: Set ownership
117133
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
118134
run: |

.github/workflows/bump-formula-pr.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
release:
44
types: [released]
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
homebrew-grafana:
811
name: homebrew-grafana
@@ -11,6 +14,8 @@ jobs:
1114
# TODO: Remove this when we no longer need a forked action in the "Update Homebrew formula" step.
1215
- name: Checkout code
1316
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
persist-credentials: false
1419

1520
- uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
1621
id: app-token
@@ -56,4 +61,3 @@ jobs:
5661
force: false # true
5762
user_name: grafana-alloybot[bot]
5863
user_email: 879451+grafana-alloybot[bot]@users.noreply.github.com
59-

.github/workflows/check-linux-build-image.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- 'tools/build-image/*'
77
- '.github/workflows/check-linux-build-image.yml'
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
check-linux-build-image:
1114
strategy:
@@ -17,6 +20,8 @@ jobs:
1720
steps:
1821
- name: Checkout
1922
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
persist-credentials: false
2025

2126
- name: Remove unnecessary files
2227
run: |

.github/workflows/check-linux-container.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- 'Dockerfile'
1313
- 'tools/ci/docker-containers'
1414
- '.github/workflows/check-linux-container.yml'
15+
16+
permissions:
17+
contents: read
18+
1519
jobs:
1620
publish_windows_container:
1721
name: Check Linux container
@@ -21,6 +25,8 @@ jobs:
2125
steps:
2226
- name: Checkout code
2327
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
persist-credentials: false
2430

2531
- name: Set ownership
2632
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989

.github/workflows/check-versioned-files.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
name: Test Versioned Files
22
on: pull_request
3+
4+
permissions:
5+
contents: read
6+
37
jobs:
48
regenerate-docs:
59
runs-on: ubuntu-latest
610
steps:
711
- name: Checkout
812
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
with:
14+
persist-credentials: false
915

1016
- name: Regenerate versioned files
1117
run: |

.github/workflows/check-windows-build-image.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ on:
55
paths:
66
- 'tools/build-image/windows/**'
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
check-windows-build-image:
1013
runs-on: windows-2019
1114
steps:
1215
- name: Checkout code
1316
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
persist-credentials: false
1419

1520
- name: Create test Windows build image
1621
uses: mr-smithers-excellent/docker-build-push@59523c638baec979a74fea99caa9e29d97e5963c # v6.4

.github/workflows/check-windows-container.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
- '.github/workflows/publish-alloy.yml'
1919
- '.github/workflows/publish-alloy-devel.yml'
2020
- '.github/workflows/publish-alloy-release.yml'
21+
22+
permissions:
23+
contents: read
24+
2125
jobs:
2226
check_windows_container:
2327
uses: ./.github/workflows/publish-alloy.yml

.github/workflows/check_docs.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
name: Check docs
22
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
37
jobs:
48
build-technical-documentation:
59
runs-on: "ubuntu-latest"
610
steps:
7-
- name: "Check out code"
11+
- name: "Checkout code"
812
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4.2.2
13+
with:
14+
persist-credentials: false
15+
916
- name: "Build technical documentation"
1017
run: >
1118
docker run

.github/workflows/create_build_image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
steps:
2222
- name: Checkout code
2323
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
persist-credentials: false
2426

2527
- name: Remove unnecessary files
2628
run: |

0 commit comments

Comments
 (0)