container-device-interface 1.1.1

CDI (Container Device Interface), is a specification, for container-runtimes, to support third-party devices.
Documentation
# https://github.com/marketplace/actions/shellcheck
name: Check shell scripts

on:
  workflow_dispatch:
  pull_request:
    types:
      - opened
      - reopened
      - synchronize

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  # Detect what files changed
  changes:
    name: Detect changes
    runs-on: ubuntu-latest
    outputs:
      scripts: ${{ steps.filter.outputs.scripts }}
      code: ${{ steps.filter.outputs.code }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          persist-credentials: false
      - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
        id: filter
        with:
          filters: |
            scripts:
              - '**.sh'
              - '**.bash'
            code:
              - '**/*.rs'
              - '**/*.toml'
              - '**/*.lock'
              - '**/*.sh'
              - '**/*.bash'
              - '**/*.yaml'
              - '**/*.yml'
              - '**/*.json'

  # Always check for scripts without .sh extension (catches bad additions)
  extension-check:
    name: Check .sh extension
    needs: changes
    if: ${{ needs.changes.outputs.code == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          persist-credentials: false

      - name: Check shell scripts have .sh extension
        run: |
          # Find files with shell shebang but without .sh extension
          bad_scripts=$(find . -type f \
            ! -path './.git/*' \
            ! -path './vendor/*' \
            ! -path './target/*' \
            ! -name '*.sh' \
            ! -name '*.bash' \
            -exec sh -c 'head -1 "$1" 2>/dev/null | grep -qE "^#!.*(bash|sh)" && echo "$1"' _ {} \;)
          if [ -n "$bad_scripts" ]; then
            echo "::error::Shell scripts must have .sh or .bash extension:"
            echo "$bad_scripts"
            exit 1
          fi
          echo "All shell scripts have correct extensions"

  shellcheck:
    needs: changes
    if: ${{ needs.changes.outputs.scripts == 'true' }}
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout the code
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Run ShellCheck
        uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca # master (2024-06-20)
        with:
          ignore_paths: "**/vendor/**"