Skip to content

Commit cc7e400

Browse files
ci: add actionlint for GitHub Actions workflow linting (#226)
1 parent b1289be commit cc7e400

File tree

7 files changed

+77
-5
lines changed

7 files changed

+77
-5
lines changed

.claude/hooks/SessionStart.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,38 @@ fi
6565

6666
composer install
6767

68+
# Install shellcheck for shell script linting (used by actionlint)
69+
echo "Checking for shellcheck..."
70+
if ! command -v shellcheck &> /dev/null; then
71+
echo "shellcheck is not installed. Installing shellcheck..."
72+
73+
if command -v apt-get &> /dev/null; then
74+
apt-get install -y shellcheck
75+
else
76+
echo "Error: apt package manager is not available. Cannot install shellcheck."
77+
exit 1
78+
fi
79+
80+
if ! command -v shellcheck &> /dev/null; then
81+
echo "Error: Failed to install shellcheck."
82+
exit 1
83+
fi
84+
85+
echo "shellcheck installed successfully!"
86+
else
87+
echo "shellcheck is already available."
88+
fi
89+
90+
# Install actionlint for GitHub Actions workflow linting
91+
echo "Checking for actionlint..."
92+
if ! command -v actionlint &> /dev/null && [ ! -f "./actionlint" ]; then
93+
echo "actionlint is not installed. Downloading actionlint..."
94+
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/v1.7.9/scripts/download-actionlint.bash) 1.7.9
95+
echo "actionlint installed successfully!"
96+
else
97+
echo "actionlint is already available."
98+
fi
99+
68100
# Install infection for mutation testing
69101
echo "Checking for infection..."
70102
if [ ! -f "infection.phar" ]; then

.github/workflows/actionlint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint GitHub Actions workflows
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
actionlint:
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Download actionlint
18+
id: get_actionlint
19+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/v1.7.9/scripts/download-actionlint.bash) 1.7.9
20+
shell: bash
21+
- name: Check workflow files
22+
run: ${{ steps.get_actionlint.outputs.executable }} -color
23+
shell: bash

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Get composer cache directory
4646
id: composer-cache
47-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
47+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
4848

4949
- name: Cache dependencies
5050
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131

3232
- name: Get composer cache directory
3333
id: composer-cache
34-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
3535

3636
- name: Cache dependencies
3737
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
@@ -83,7 +83,7 @@ jobs:
8383

8484
- name: Get composer cache directory
8585
id: composer-cache
86-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
86+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
8787

8888
- name: Cache dependencies
8989
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
@@ -114,7 +114,7 @@ jobs:
114114

115115
- name: Get composer cache directory
116116
id: composer-cache
117-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
117+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
118118

119119
- name: Cache dependencies
120120
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
@@ -147,7 +147,7 @@ jobs:
147147

148148
- name: Get composer cache directory
149149
id: composer-cache
150-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
150+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
151151

152152
- name: Cache dependencies
153153
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ infection.phar.asc
1414
*.har
1515
infection*.txt
1616
infection-report.html
17+
actionlint

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ repos:
88
- id: check-added-large-files
99
- id: check-merge-conflict
1010
- id: detect-private-key
11+
- repo: https://github.com/rhysd/actionlint
12+
rev: v1.7.9
13+
hooks:
14+
- id: actionlint
1115
- repo: https://github.com/compilerla/conventional-pre-commit
1216
rev: v3.0.0
1317
hooks:

renovate.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
],
1818
"depNameTemplate": "infection/infection",
1919
"datasourceTemplate": "github-releases"
20+
},
21+
{
22+
"customType": "regex",
23+
"managerFilePatterns": [
24+
"/^\\.github/workflows/actionlint\\.yml$/",
25+
"/^\\.claude/hooks/SessionStart\\.sh$/"
26+
],
27+
"matchStrings": [
28+
"rhysd/actionlint/(?<currentValue>v[0-9.]+)/scripts/download-actionlint\\.bash"
29+
],
30+
"depNameTemplate": "rhysd/actionlint",
31+
"datasourceTemplate": "github-releases"
2032
}
2133
],
2234
"packageRules": [

0 commit comments

Comments
 (0)