This commit is contained in:
JEEVITHA KANNAN K S 2024-10-10 03:15:32 +00:00 committed by GitHub
commit d2a58a10ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
id: get_sh_files
run: |
sh_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs | grep '\.sh$' || true)
if [ -n "$sh_files" ]; then
echo "$sh_files" > changed_files
echo "changed=1" >> $GITHUB_OUTPUT
else
echo "changed=0" >> $GITHUB_OUTPUT
fi
- name: Install devscripts - name: Install devscripts
if: steps.get_sh_files.outputs.changed == 1 run: sudo apt-get update && sudo apt-get install -y devscripts
run: sudo apt-get update && sudo apt-get install 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: |
files=$(find . -type f -name "*.sh" | tr '\n' ' ')
echo "files=${files:-none}" >> $GITHUB_ENV
- 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
echo "FILES=${{ env.files }}" >> $GITHUB_ENV
fi
- 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