Skip to content

Commit ec186e4

Browse files
authored
CI: Update workflows (#510)
* ci(gh-workflows): fix up zizmor warnings * ci(gh-workflows): replace gh secrets with vault * ci(gh-workflows): fix stray space preventing zizmor from parsing integration-tests
1 parent 328f19a commit ec186e4

File tree

4 files changed

+66
-20
lines changed

4 files changed

+66
-20
lines changed

.github/workflows/automatic-update.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
jobs:
99
update-grafana:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
1113
steps:
1214
- name: Generate token
1315
id: generate_token
@@ -18,6 +20,8 @@ jobs:
1820

1921
- name: Checkout repository
2022
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
persist-credentials: false
2125

2226
- name: Update Grafana version
2327
run: |

.github/workflows/check-readme-links.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
name: Linkspector
2+
23
on: [pull_request]
4+
35
jobs:
46
check-links:
57
name: runner / linkspector
68
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
711
steps:
812
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
with:
14+
persist-credentials: false
915
- name: Run linkspector
1016
uses: umbrelladocs/action-linkspector@a0567ce1c7c13de4a2358587492ed43cab5d0102 # v1.3.4
1117
with:

.github/workflows/integration-tests.yml

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ on:
66
concurrency:
77
group: integration-tests-${{ github.ref }}
88
cancel-in-progress: true
9+
910
permissions:
10-
contents: write
11-
id-token: write
12-
pull-requests: write
11+
contents: read
1312

1413
jobs:
1514
setup-matrix:
@@ -23,6 +22,8 @@ jobs:
2322
steps:
2423
- name: Checkout
2524
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
with:
26+
persist-credentials: false
2627
- name: Setup plugin dir variable
2728
id: set-plugin-dirs
2829
run: echo "pluginDirs=$(find ./examples -type d -name "src" -not -path "*/node_modules*" -maxdepth 3 -exec test -e "{}/plugin.json" \; -print | sed "s/\/src$//" | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
@@ -58,11 +59,15 @@ jobs:
5859
GF_INSTALL_PLUGINS: "marcusolsson-static-datasource"
5960
steps:
6061
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
62+
with:
63+
persist-credentials: false
6164

6265
- name: Set the name of the plugin-example to be tested
6366
id: example-name
6467
run: |
65-
echo "PLUGIN_NAME=$(basename ${{ matrix.pluginDir }})" >> $GITHUB_OUTPUT
68+
echo "PLUGIN_NAME=$(basename $PLUGIN_NAME)" >> $GITHUB_OUTPUT
69+
env:
70+
PLUGIN_NAME: ${{ matrix.pluginDir }}
6671

6772
- name: Setup node version
6873
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
@@ -120,13 +125,17 @@ jobs:
120125
run: |
121126
echo "PLUGIN_ID=$(cat src/plugin.json | jq -r '.id')" >> $GITHUB_ENV
122127
echo "EXPECTED_GRAFANA_VERSION=$(npx semver@latest $(cat src/plugin.json | jq -r '.dependencies.grafanaDependency') -c)" >> $GITHUB_ENV
123-
echo "CANARY_VERSION=${{ needs.setup-matrix.outputs.canaryVersion }}" >> $GITHUB_ENV
124-
echo "CANARY_DOCKER_TAG=${{ needs.setup-matrix.outputs.canaryDockerTag }}" >> $GITHUB_ENV
125-
echo "LATEST_STABLE_VERSION=${{ needs.setup-matrix.outputs.latestVersion }}" >> $GITHUB_ENV
128+
echo "CANARY_VERSION=$CANARY_VERSION" >> $GITHUB_ENV
129+
echo "CANARY_DOCKER_TAG=$CANARY_DOCKER_TAG" >> $GITHUB_ENV
130+
echo "LATEST_STABLE_VERSION=$LATEST_STABLE_VERSION" >> $GITHUB_ENV
126131
if [ -f "${PWD}/.env" ]; then
127132
echo "ENV_FILE_OPTION=--env-file ${PWD}/.env" >> $GITHUB_ENV
128133
fi
129134
working-directory: ${{ matrix.pluginDir }}
135+
env:
136+
CANARY_VERSION: ${{ needs.setup-matrix.outputs.canaryVersion }}
137+
CANARY_DOCKER_TAG: ${{ needs.setup-matrix.outputs.canaryDockerTag }}
138+
LATEST_STABLE_VERSION: ${{ needs.setup-matrix.outputs.latestVersion }}
130139

131140
- name: Has Integration Tests
132141
id: has-integration-tests
@@ -184,10 +193,12 @@ jobs:
184193
if: steps.has-integration-tests.outputs.DIR == 'true' && steps.should-run-expected-latest-tests.outcome == 'success'
185194
id: expected-version-tests
186195
continue-on-error: true
187-
run: npm run e2e --prefix ${{ matrix.pluginDir }}
196+
run: npm run e2e --prefix $PLUGIN_DIR
197+
env:
198+
PLUGIN_DIR: ${{ matrix.pluginDir }}
188199

189200
- name: Expected - Upload e2e test summary
190-
uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@main
201+
uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@main # zizmor: ignore[unpinned-uses]
191202
if: ${{ always() && steps.expected-version-tests.outcome == 'failure' }}
192203
with:
193204
report-dir: ${{ matrix.pluginDir }}/playwright-report
@@ -225,10 +236,12 @@ jobs:
225236
if: steps.has-integration-tests.outputs.DIR == 'true' && steps.should-run-expected-latest-tests.outcome == 'success'
226237
id: latest-version-tests
227238
continue-on-error: true
228-
run: npm run e2e --prefix ${{ matrix.pluginDir }}
239+
run: npm run e2e --prefix $PLUGIN_DIR
240+
env:
241+
PLUGIN_DIR: ${{ matrix.pluginDir }}
229242

230243
- name: Latest - Upload e2e test summary
231-
uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@main
244+
uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@main # zizmor: ignore[unpinned-uses]
232245
if: ${{ always() && steps.latest-version-tests.outcome == 'failure' }}
233246
with:
234247
report-dir: ${{ matrix.pluginDir }}/playwright-report
@@ -291,10 +304,12 @@ jobs:
291304
if: steps.has-integration-tests.outputs.DIR == 'true'
292305
id: canary-version-tests
293306
continue-on-error: true
294-
run: npm run e2e --prefix ${{ matrix.pluginDir }}
307+
run: npm run e2e --prefix $PLUGIN_DIR
308+
env:
309+
PLUGIN_DIR: ${{ matrix.pluginDir }}
295310

296311
- name: Canary - Upload e2e test summary
297-
uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@main
312+
uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@main # zizmor: ignore[unpinned-uses]
298313
if: ${{ always() && steps.canary-version-tests.outcome == 'failure' }}
299314
with:
300315
report-dir: ${{ matrix.pluginDir }}/playwright-report
@@ -322,21 +337,28 @@ jobs:
322337
publish-report:
323338
if: ${{ always() }}
324339
needs: [run-integration-tests]
340+
permissions:
341+
contents: write
342+
pull-requests: write
325343
runs-on: ubuntu-latest
326344
steps:
327345
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
346+
with:
347+
persist-credentials: false
328348
- name: Publish report
329-
uses: grafana/plugin-actions/playwright-gh-pages/deploy-report-pages@main
349+
uses: grafana/plugin-actions/playwright-gh-pages/deploy-report-pages@main # zizmor: ignore[unpinned-uses]
330350
with:
331351
github-token: ${{ secrets.GITHUB_TOKEN }}
332352

333353
notify:
334354
if: ${{ (always() && github.event_name == 'schedule') }}
335355
runs-on: ubuntu-latest
336356
needs: [run-integration-tests]
357+
permissions:
358+
id-token: write
337359
steps:
338360
- id: get-secrets
339-
uses: grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets-v1.1.0
361+
uses: grafana/shared-workflows/actions/get-vault-secrets@28361cdb22223e5f1e34358c86c20908e7248760 # get-vault-secrets-v1.1.0
340362
with:
341363
# Secrets placed in the ci/repo/grafana/grafana-plugin-examples path in Vault
342364
repo_secrets: |
@@ -397,7 +419,7 @@ jobs:
397419
},
398420
{
399421
"type": "mrkdwn",
400-
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github. run_id }}?pr=${{ github.event.number }}|See Playwright reports>"
422+
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.number }}|See Playwright reports>"
401423
}
402424
]
403425
}

.github/workflows/notify-plugin-tools.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
types: [closed]
66
branches: [main]
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
notify-plugin-tools:
1013
if: github.event.pull_request.merged == true
@@ -14,26 +17,37 @@ jobs:
1417
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1518
with:
1619
fetch-depth: 0
20+
persist-credentials: false
1721

1822
- name: Check for relevant file changes
1923
id: check_files
2024
run: |
21-
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.merge_commit_sha }})
25+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} $COMMIT_SHA)
2226
echo "$CHANGED_FILES" > /tmp/changed_files.txt
2327
if grep -i -E "\.(ts|tsx|go)$" /tmp/changed_files.txt; then
2428
echo "has_relevant_changes=true" >> "$GITHUB_OUTPUT"
2529
else
2630
echo "has_relevant_changes=false" >> "$GITHUB_OUTPUT"
2731
fi
2832
shell: bash
33+
env:
34+
COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }}
35+
36+
- id: get-secrets
37+
uses: grafana/shared-workflows/actions/get-vault-secrets@28361cdb22223e5f1e34358c86c20908e7248760 # get-vault-secrets-v1.1.0
38+
with:
39+
# Secrets placed in the ci/repo/grafana/grafana-plugin-examples path in Vault
40+
repo_secrets: |
41+
GITHUB_APP_ID=plugins-platform-bot-app:app_id
42+
GITHUB_APP_PRIVATE_KEY=plugins-platform-bot-app:app_pem
2943
3044
- name: Generate token
3145
if: steps.check_files.outputs.has_relevant_changes == 'true'
3246
id: generate_token
33-
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
47+
uses: actions/create-github-app-token@3ff1caaa28b64c9cc276ce0a02e2ff584f3900c5 # v2.0.2
3448
with:
35-
app_id: ${{ secrets.APP_ID }}
36-
private_key: ${{ secrets.APP_PEM }}
49+
app-id: ${{ env.GITHUB_APP_ID }}
50+
private-key: ${{ env.GITHUB_APP_PRIVATE_KEY }}
3751

3852
- name: Repository Dispatch
3953
if: steps.check_files.outputs.has_relevant_changes == 'true'

0 commit comments

Comments
 (0)