forked from kubeflow/manifests
-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (36 loc) · 1.45 KB
/
bash_formatter.yaml
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
name: Proper Formatting on bash files
on: [push, pull_request]
jobs:
format_bash_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install ShellCheck
run: sudo apt install -y shellcheck
- name: Bash Formatting Guidelines
run: |
echo "### Bash Files Formatting Guidelines ###
If there are errors and warnings regarding your bash files,
You can check that error code definitions in https://www.shellcheck.net/wiki/ site.
You can correct them using the https://www.shellcheck.net/ site.
You have to ignore disable errors in .shellcheckrc file.
"
- name: Fetch master branch
run: git fetch origin master
- name: Set up changed files
id: changed_files
run: |
git diff --name-only origin/master...HEAD | grep -E '^.*\.sh$' | grep -v '^apps/' > changed_files_in_PR.txt || true
if [ ! -s changed_files_in_PR.txt ]; then
echo "No bash files have changed in this PR."
fi
- name: Display changed files
if: always() # Always run this step
run: cat changed_files_in_PR.txt || echo "No bash files have changed in this PR."
- name: Run ShellCheck on changed files
if: steps.changed_files.outputs.changed_files != ''
run: |
cat changed_files_in_PR.txt | xargs -I {} shellcheck {} || echo "No changes needed for the bash files."
shell: bash