fail gh action if pipeline failed in .github/workflows/pipeline_test.… #4
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 YAML files | |
on: [push, pull_request] | |
jobs: | |
format_YAML_files: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install yamllint | |
run: pip install yamllint | |
- name: YAML Formatting Guidelines | |
run: | | |
echo "### YAML Formatting Guidelines ### | |
If there is a formatting error in your YAML file, you will see errors like the one below: | |
'Error: 6:4 [indentation] wrong indentation: expected 2 but found 3' | |
To fix these errors, refer to the YAML formatting rules at: | |
https://yamllint.readthedocs.io/en/stable/rules.html# | |
Search for the keyword inside the brackets [] in the error message. In this example, it's 'indentation'. | |
Note: Some rules have been customized in the '.yamllint.yaml' file. Below is the content of that file: | |
extends: default | |
rules: | |
document-start: | |
present: false | |
document-end: | |
present: false | |
indentation: | |
indent-sequences: false | |
line-length: | |
max: 400 | |
" | |
- name: Fetch master branch | |
run: git fetch origin master | |
- name: Set up changed files | |
run: | | |
git diff --name-only origin/master...HEAD | grep -E '^common/.*\.ya?ml$|^example/.*\.ya?ml$' > changed_files_in_PR.txt || true | |
- name: Display changed files | |
run: cat changed_files_in_PR.txt | |
- name: Run yamllint on changed files | |
run: | | |
chmod +x ./run_yamllint.sh | |
./run_yamllint.sh | |
shell: bash | |