mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 15:43:17 +02:00
- Add pull_request_target trigger to check PRs from forks - Add explicit failure message with instructions - Create BRANCH_PROTECTION.md with setup guide - Ensure workflow runs on all PRs targeting main/master Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com>
71 lines
1.9 KiB
YAML
71 lines
1.9 KiB
YAML
name: Shell Script Linting
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
paths:
|
|
- '**.sh'
|
|
- '**.bash'
|
|
- '**.zsh'
|
|
- '.github/workflows/shell-check.yml'
|
|
- 'scripts/meta/shell_check.sh'
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
paths:
|
|
- '**.sh'
|
|
- '**.bash'
|
|
- '**.zsh'
|
|
- '.github/workflows/shell-check.yml'
|
|
- 'scripts/meta/shell_check.sh'
|
|
# Also run on pull_request_target for forks to ensure all PRs are checked
|
|
pull_request_target:
|
|
branches: [ main, master ]
|
|
paths:
|
|
- '**.sh'
|
|
- '**.bash'
|
|
- '**.zsh'
|
|
- '.github/workflows/shell-check.yml'
|
|
- 'scripts/meta/shell_check.sh'
|
|
|
|
jobs:
|
|
shellcheck:
|
|
name: Lint Shell Scripts
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
# For pull_request_target, checkout the PR head
|
|
ref: ${{ github.event.pull_request.head.sha || github.ref }}
|
|
|
|
- name: Install shellcheck
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y shellcheck
|
|
|
|
- name: Install shfmt
|
|
run: |
|
|
cd /tmp
|
|
SHFMT_VERSION="3.8.0"
|
|
wget -q "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64" -O shfmt
|
|
chmod +x shfmt
|
|
sudo mv shfmt /usr/local/bin/
|
|
shfmt -version
|
|
|
|
- name: Run shell_check.sh
|
|
run: |
|
|
bash scripts/meta/shell_check.sh --skip-install
|
|
|
|
- name: Report status
|
|
if: success()
|
|
run: echo "✅ All shell scripts passed linting checks!"
|
|
|
|
- name: Fail on linting errors
|
|
if: failure()
|
|
run: |
|
|
echo "❌ Shell script linting failed!"
|
|
echo "This check is required to merge PRs into main/master."
|
|
echo "Please run 'bash scripts/meta/shell_check.sh' locally and fix any issues."
|
|
exit 1
|