Repository navigation
Add shellcheck workflow for changed scripts #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
183436e
Initial plan
Copilot ea3c406
Add GitHub workflow to run shellcheck on changed scripts
Copilot 1324866
Fix shellcheck workflow to properly handle filenames with spaces
Copilot bb7761b
Simplify shellcheck workflow and use proper iteration method
Copilot b5b7ad7
Use newline separator to properly handle filenames with spaces
Copilot c497173
Add explicit permissions to workflow for security
Copilot cfef4cd
Replace third-party action with custom git commands
Copilot d3cadf9
Fix git diff syntax and remove redundant file check
Copilot 825522d
Use three-dot range for proper PR diff comparison
Copilot ce95a12
Quote exit_code variable for safer shell scripting
Copilot 70741c3
Merge branch 'main' into copilot/add-github-workflow-shellcheck
mikeharder 6c3079b
Update to latest versions: checkout@v6 and ubuntu-slim runner
Copilot e6e8379
Apply suggestion from @mikeharder
mikeharder 4cf74e4
Move permissions to workflow level and update instructions
Copilot 2f0c03b
Add temporary shellcheck error for workflow testing (SC2086)
Copilot 6c381c3
Revert temporary shellcheck error (revert 2f0c03b)
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Shellcheck | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - '**.sh' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| shellcheck: | ||
| name: Shellcheck | ||
| runs-on: ubuntu-slim | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Run shellcheck on changed files | ||
| run: | | ||
| # Get the base branch | ||
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
| HEAD_SHA="${{ github.sha }}" | ||
|
|
||
| echo "Comparing $BASE_SHA...$HEAD_SHA" | ||
| echo "" | ||
|
|
||
| # Get changed shell scripts | ||
| CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT "$BASE_SHA...$HEAD_SHA" | grep '\.sh$' || true) | ||
|
|
||
| if [ -z "$CHANGED_FILES" ]; then | ||
| echo "No shell scripts changed in this PR" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Changed shell scripts:" | ||
| echo "$CHANGED_FILES" | ||
| echo "" | ||
|
|
||
| # Run shellcheck on each changed file | ||
| exit_code=0 | ||
| while IFS= read -r file; do | ||
| if [ -n "$file" ]; then | ||
| echo "Checking $file..." | ||
| if ! shellcheck "$file"; then | ||
| exit_code=1 | ||
| fi | ||
| fi | ||
| done <<< "$CHANGED_FILES" | ||
|
|
||
| exit "$exit_code" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.