mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-24 06:01:55 +00:00
refact(ci): bashisms.yml (#793)
* Refact bashisms.yml * Update bashisms.yml
This commit is contained in:
parent
9cc57330dc
commit
5987d0d808
48
.github/workflows/bashisms.yml
vendored
48
.github/workflows/bashisms.yml
vendored
|
@ -3,7 +3,7 @@ name: Check for bashisms
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- core/tabs/**
|
- 'core/tabs/**/*.sh'
|
||||||
merge_group:
|
merge_group:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
@ -15,31 +15,33 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: git fetch origin ${{ github.base_ref }}
|
- run: git fetch origin ${{ github.base_ref }}
|
||||||
|
|
||||||
- name: Get a list of changed script files
|
- name: Install devscripts
|
||||||
id: get_sh_files
|
run: sudo apt-get update && sudo apt-get install -y devscripts
|
||||||
|
|
||||||
|
- name: Get changed .sh files (PR only)
|
||||||
|
id: changed-sh-files
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
uses: tj-actions/changed-files@v45
|
||||||
|
with:
|
||||||
|
files: '**/*.sh'
|
||||||
|
|
||||||
|
- name: Get all .sh files (if workflow dispatched)
|
||||||
|
id: sh-files
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
run: |
|
run: |
|
||||||
sh_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs | grep '\.sh$' || true)
|
files=$(find . -type f -name "*.sh" | tr '\n' ' ')
|
||||||
if [ -n "$sh_files" ]; then
|
echo "files=${files:-none}" >> $GITHUB_ENV
|
||||||
echo "$sh_files" > changed_files
|
|
||||||
echo "changed=1" >> $GITHUB_OUTPUT
|
- name: Set FILES for bashism check
|
||||||
|
id: set-files
|
||||||
|
run: |
|
||||||
|
if [[ "${{ steps.changed-sh-files.outputs.any_changed }}" == 'true' ]]; then
|
||||||
|
echo "FILES=${{ steps.changed-sh-files.outputs.all_changed_files }}" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "changed=0" >> $GITHUB_OUTPUT
|
echo "FILES=${{ env.files }}" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Install devscripts
|
|
||||||
if: steps.get_sh_files.outputs.changed == 1
|
|
||||||
run: sudo apt-get update && sudo apt-get install devscripts
|
|
||||||
|
|
||||||
- name: Check for bashisms
|
- name: Check for bashisms
|
||||||
if: steps.get_sh_files.outputs.changed == 1
|
|
||||||
run: |
|
run: |
|
||||||
echo "Running for:\n$(cat changed_files)\n"
|
IFS=' ' read -r -a file_array <<< "$FILES"
|
||||||
for file in $(cat changed_files); do
|
checkbashisms "${file_array[@]}"
|
||||||
if [[ -f "$file" ]]; then
|
|
||||||
checkbashisms "$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Remove the created file
|
|
||||||
if: steps.get_sh_files.outputs.changed == 1
|
|
||||||
run: rm changed_files
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user