-
Notifications
You must be signed in to change notification settings - Fork 27
63 lines (56 loc) · 1.76 KB
/
check-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
# Check commits and incoming PRs that change anything under ci/.
name: Check CI
'on':
push:
paths:
- 'ci/**'
pull_request:
paths:
- 'ci/**'
types:
- opened
- reopened
- edited
- ready_for_review
- synchronize
permissions: {}
jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install prerequisites
run: |
sudo apt update -y
sudo apt install -y shellcheck jq
mkdir ~/bin
cat <<\EOF > ~/bin/sc2github
#!/usr/bin/jq -rf
.comments[] |
.gh_level = {"error": "error", "warning": "warning",
"info": "notice", "style": "notice"}[.level] |
"::\(.gh_level) title=SC\(.code),file=\(.file),line=\(.line)," +
"col=\(.column),endLine=\(.endLine),endColumn=\(.endColumn)::\(.message)"
EOF
chmod +x ~/bin/sc2github
echo ~/bin >> "$GITHUB_PATH"
- name: Check CI shell scripts
# Run the "bash" with -o pipefail, not the default one without.
shell: bash
run: |
find ci -type f -name '*.sh' -print0 |
xargs -tr0 shellcheck -f json1 |
sc2github
- name: Check .env files
# Run even if the previous step failed. A failure in the previous step
# will still fail the job as a whole.
if: ${{ success() || failure() }}
# Run the "bash" with -o pipefail, not the default one without.
shell: bash
run: |
find ci/repo-config -type f -name '*.env' -print0 |
# SC2034 is the "$VAR appears unused" warning.
xargs -tr0 shellcheck -f json1 -s bash --exclude=SC2034 |
sc2github