Skip to content
This repository was archived by the owner on Feb 2, 2026. It is now read-only.

Commit ffa696e

Browse files
enh(ci): implement hash check for actions in actionlint (#45)
* enh(ci): implement hash check for actions in actionlint * removed unnecessary packaging mention * fix actions linting * fix yaml linting command * replace deprecated ::set_output commands * final fixes * update action * remove restore key
1 parent a93a887 commit ffa696e

File tree

3 files changed

+99
-27
lines changed

3 files changed

+99
-27
lines changed

.github/workflows/actionlint.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: actionlint
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
on:
8+
workflow_dispatch:
9+
pull_request:
10+
branches:
11+
- master
12+
paths:
13+
- ".github/**"
14+
15+
jobs:
16+
action-lint:
17+
runs-on: ubuntu-24.04
18+
steps:
19+
- name: Checkout sources
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
22+
- name: Download actionlint
23+
id: get_actionlint
24+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/v1.7.7/scripts/download-actionlint.bash)
25+
shell: bash
26+
27+
- name: Check workflow files
28+
env:
29+
SHELLCHECK_OPTS: "--severity=error"
30+
run: |
31+
${{ steps.get_actionlint.outputs.executable }} \
32+
-ignore 'label "centreon-(collect-arm64|ubuntu-22.04|common)" is unknown' \
33+
-ignore 'label "infrastructure" is unknown' \
34+
-ignore '"github.head_ref" is potentially untrusted' \
35+
-pyflakes= \
36+
-color
37+
shell: bash
38+
39+
- name: Ensure SHA pinned actions
40+
uses: centreon/github-actions-ensure-sha-pinned-actions@47d553c67ceb08ad660deaeb3b994e47a3dd8fc3 # v3.0.23.3
41+
42+
yaml-lint:
43+
runs-on: ubuntu-24.04
44+
steps:
45+
- name: Checkout sources
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
48+
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
49+
with:
50+
python-version: '3.12'
51+
52+
- name: Install Yaml
53+
run: pip install yamllint==1.35.1
54+
55+
- name: Add Yaml Lint Rules
56+
run: |
57+
cat <<EOF >>./yamllint_rules.yml
58+
extends: default
59+
60+
rules:
61+
document-start: disable
62+
line-length: disable
63+
truthy:
64+
check-keys: false
65+
level: error
66+
indentation:
67+
spaces: 2
68+
indent-sequences: true
69+
check-multi-line-strings: false
70+
comments:
71+
ignore-shebangs: true
72+
min-spaces-from-content: 1
73+
comments-indentation: disable
74+
new-lines:
75+
type: unix
76+
new-line-at-end-of-file: enable
77+
EOF
78+
79+
- name: Lint YAML files
80+
run: yamllint -c ./yamllint_rules.yml ./.github/workflows/

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,21 @@ jobs:
2121

2222
- name: Get yarn cache directory path
2323
id: yarn-cache-dir-path
24-
run: echo "::set-output name=dir::$(yarn cache dir)"
24+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
2525

2626
- name: Cache yarn cache
27-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # 3.3.3
27+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
2828
id: cache-yarn-cache
2929
with:
3030
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
3131
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
32-
restore-keys: |
33-
${{ runner.os }}-yarn-
3432

3533
- name: Cache node_modules
3634
id: cache-node-modules
37-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # 3.3.3
35+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3836
with:
3937
path: node_modules
40-
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
41-
restore-keys: |
42-
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
38+
key: ${{ runner.os }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
4339

4440
- name: Install dependencies
4541
run: yarn install --frozen-lockfile
@@ -54,7 +50,7 @@ jobs:
5450
run: |
5551
if [ -f "Magefile.go" ]
5652
then
57-
echo "::set-output name=has-backend::true"
53+
echo "has-backend='true'" >> $GITHUB_OUTPUT
5854
fi
5955
6056
- name: Setup Go environment

.github/workflows/release.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,21 @@ jobs:
2424

2525
- name: Get yarn cache directory path
2626
id: yarn-cache-dir-path
27-
run: echo "::set-output name=dir::$(yarn cache dir)"
27+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
2828

2929
- name: Cache yarn cache
30-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # 3.3.3
30+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3131
id: cache-yarn-cache
3232
with:
3333
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
3434
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-yarn-
3735

3836
- name: Cache node_modules
3937
id: cache-node-modules
40-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # 3.3.3
38+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4139
with:
4240
path: node_modules
43-
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
44-
restore-keys: |
45-
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
41+
key: ${{ runner.os }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
4642

4743
- name: Install dependencies
4844
run: yarn install --frozen-lockfile;
@@ -58,7 +54,7 @@ jobs:
5854
run: |
5955
if [ -f "Magefile.go" ]
6056
then
61-
echo "::set-output name=has-backend::true"
57+
echo "has-backend=true" >> $GITHUB_OUTPUT
6258
fi
6359
6460
- name: Test backend
@@ -91,19 +87,19 @@ jobs:
9187
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
9288
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
9389
94-
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
95-
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
96-
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
97-
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
98-
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
90+
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
91+
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
92+
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
93+
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
94+
echo "archive-checksum=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_OUTPUT
9995
100-
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
96+
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
10197
10298
- name: Read changelog
10399
id: changelog
104100
run: |
105101
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
106-
echo "::set-output name=path::release_notes.md"
102+
echo "path=release_notes.md" >> $GITHUB_OUTPUT
107103
108104
- name: Check package version
109105
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
@@ -114,7 +110,7 @@ jobs:
114110
mv dist ${{ steps.metadata.outputs.plugin-id }}
115111
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
116112
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
117-
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
113+
echo "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
118114
119115
- name: Lint plugin
120116
run: |
@@ -151,7 +147,7 @@ jobs:
151147
- name: Add checksum to release
152148
id: upload-checksum-asset
153149
# caution action not maintained since 2021
154-
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
150+
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
155151
env:
156152
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157153
with:

0 commit comments

Comments
 (0)