Skip to content

checking functionalities of linting #44

checking functionalities of linting

checking functionalities of linting #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
id: lint
run: |
if grep -q 'No bash files have changed in this PR.' changed_files_in_PR.txt; then
echo "No bash files have changed in this PR."
else
cat changed_files_in_PR.txt | xargs -I {} shellcheck {} || exit 1
fi
shell: bash
- name: Check Bash lint results
if: success() && steps.lint.outcome == 'success'
run: echo "No styling issues with Bash files."
shell: bash