Check the linting working by changing a yaml file #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |