Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
${{ github.repository != 'google-github-actions/.github' }}
outputs:
lint-targets: '${{ steps.lint-targets.outputs.lint-targets }}'
gomod-dirs: '${{ steps.lint-targets.outputs.gomod-dirs }}'
packagejson-dirs: '${{ steps.lint-targets.outputs.packagejson-dirs }}'
ratchet-files: '${{ steps.lint-targets.outputs.ratchet-files }}'
steps:
- name: 'Checkout'
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
Expand All @@ -48,14 +47,15 @@ jobs:
run: |-
set -euo pipefail

# match_files determines if the current git repository has any files
# matching the given pattern. This has been performance tested
# against a shallow checkout of chromium (future changes should be
# tested in the same manner).
find_files() {
local filepattern="${1}"
git ls-tree -r --name-only "${REF}" | grep -E "${filepattern}" | sort || true
}

match_files() {
local filepattern="${1}"
matches="$(git ls-tree -r --name-only "${REF}" | grep -m 1 -E "${filepattern}")"
code="$?"
code="${?}"
if [[ -n "${matches}" ]]; then
# Ignore exit codes because we found a match.
# Exit code 141 and higher may occur because we exit early.
Expand All @@ -68,8 +68,11 @@ jobs:
if match_files '.*(\.dockerfile|Dockerfile)$'; then
TARGETS+=("docker")
fi
if match_files '.github/(actions|workflows)/.*\.(yaml|yml)$'; then
if match_files '(action\.(yaml|yml))|(\.github/(actions|workflows)/.*\.(yaml|yml))$'; then
TARGETS+=("github" "ratchet")
RATCHET_FILES="$(find_files '(action\.(yaml|yml))|(\.github/(actions|workflows)/.*\.(yaml|yml))$' | tr '\n' ' ')"
echo "::debug::Found ratchetable files: ${RATCHET_FILES}"
echo "ratchet-files=${RATCHET_FILES}" >> "${GITHUB_OUTPUT}"
fi
if match_files 'go.mod$'; then
TARGETS+=("go")
Expand Down Expand Up @@ -157,7 +160,7 @@ jobs:
${{ matrix.lint-target == 'ratchet' }}
uses: 'sethvargo/ratchet@main' # ratchet:exclude
with:
files: './.github/actions/**/*.yml ./.github/workflows/*.yml'
files: '${{ needs.init.outputs.ratchet-files }}'

- name: 'Lint (Shell)'
if: |-
Expand Down