-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (86 loc) · 3.17 KB
/
reusable-bash-shellcheck.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# helpful wiki
# link: https://www.shellcheck.net/wiki/
name: reusable bash shellcheck
on:
workflow_call: {}
jobs:
bash-shellcheck:
name: bash-shellcheck
runs-on: ubuntu-latest
steps:
- if: ${{ startsWith(github.repository, 'GeoNet/') == false }}
name: require GeoNet org
run: |
exit 1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- id: run-info
name: collect job run info
run: |
all_shell_scripts=()
while IFS=$'\n' read -r script; do
git check-ignore -q "$script" || all_shell_scripts+=("$script")
done < <(grep -irl '#!.*sh' . --exclude-dir={_\*,.git\*,vendor\*})
echo "scripts=${all_shell_scripts[@]}" >> $GITHUB_OUTPUT
- name: shellcheck
if: ${{ steps.run-info.outputs.scripts }}
run: |
docker run \
-e "ACTIONS_CACHE_URL" \
-e "ACTIONS_RUNTIME_TOKEN" \
-e "ACTIONS_RUNTIME_URL" \
-e "GITHUB_ACTION" \
-e "GITHUB_ACTION_REF" \
-e "GITHUB_ACTION_REPOSITORY" \
-e "GITHUB_ACTOR" \
-e "GITHUB_ACTOR_ID" \
-e "GITHUB_API_URL" \
-e "GITHUB_BASE_REF" \
-e "GITHUB_ENV" \
-e "GITHUB_EVENT_NAME" \
-e "GITHUB_EVENT_PATH" \
-e "GITHUB_GRAPHQL_URL" \
-e "GITHUB_HEAD_REF" \
-e "GITHUB_JOB" \
-e "GITHUB_OUTPUT" \
-e "GITHUB_PATH" \
-e "GITHUB_REF" \
-e "GITHUB_REF_NAME" \
-e "GITHUB_REF_PROTECTED" \
-e "GITHUB_REF_TYPE" \
-e "GITHUB_REPOSITORY" \
-e "GITHUB_REPOSITORY_ID" \
-e "GITHUB_REPOSITORY_OWNER" \
-e "GITHUB_REPOSITORY_OWNER_ID" \
-e "GITHUB_RETENTION_DAYS" \
-e "GITHUB_RUN_ATTEMPT" \
-e "GITHUB_RUN_ID" \
-e "GITHUB_RUN_NUMBER" \
-e "GITHUB_SERVER_URL" \
-e "GITHUB_SHA" \
-e "GITHUB_STATE" \
-e "GITHUB_STEP_SUMMARY" \
-e "GITHUB_TRIGGERING_ACTOR" \
-e "GITHUB_WORKFLOW" \
-e "GITHUB_WORKFLOW_REF" \
-e "GITHUB_WORKFLOW_SHA" \
-e "GITHUB_WORKSPACE" \
-e "HOME" \
-e "INPUT_ARGS" \
-e "RUNNER_ARCH" \
-e "RUNNER_ENVIRONMENT" \
-e "RUNNER_NAME" \
-e "RUNNER_OS" \
-e "RUNNER_TEMP" \
-e "RUNNER_TOOL_CACHE" \
-e "RUNNER_WORKSPACE" \
-e CI=true \
-e GITHUB_ACTIONS=true \
-e GITHUB_EVENT_PATH=/github/workflow/event.json \
-v "$PWD":"/github/workspace" \
-v "/home/runner/work/_temp/_github_home":"/github/home" \
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
-v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" \
--workdir /github/workspace \
--entrypoint shellcheck \
ghcr.io/geonet/base-images/shellcheck:v0.9.0 \
--external-sources --exclude=2230 --color=auto ${{ steps.run-info.outputs.scripts }}