Skip to content

Commit 145cb9a

Browse files
authored
Check additional YAML file paths for ratchet (#43)
1 parent 525ebd3 commit 145cb9a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

.github/workflows/lint.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ jobs:
3131
${{ github.repository != 'google-github-actions/.github' }}
3232
outputs:
3333
lint-targets: '${{ steps.lint-targets.outputs.lint-targets }}'
34-
gomod-dirs: '${{ steps.lint-targets.outputs.gomod-dirs }}'
35-
packagejson-dirs: '${{ steps.lint-targets.outputs.packagejson-dirs }}'
34+
ratchet-files: '${{ steps.lint-targets.outputs.ratchet-files }}'
3635
steps:
3736
- name: 'Checkout'
3837
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
@@ -48,14 +47,15 @@ jobs:
4847
run: |-
4948
set -euo pipefail
5049
51-
# match_files determines if the current git repository has any files
52-
# matching the given pattern. This has been performance tested
53-
# against a shallow checkout of chromium (future changes should be
54-
# tested in the same manner).
50+
find_files() {
51+
local filepattern="${1}"
52+
git ls-tree -r --name-only "${REF}" | grep -E "${filepattern}" | sort || true
53+
}
54+
5555
match_files() {
5656
local filepattern="${1}"
5757
matches="$(git ls-tree -r --name-only "${REF}" | grep -m 1 -E "${filepattern}")"
58-
code="$?"
58+
code="${?}"
5959
if [[ -n "${matches}" ]]; then
6060
# Ignore exit codes because we found a match.
6161
# Exit code 141 and higher may occur because we exit early.
@@ -68,8 +68,11 @@ jobs:
6868
if match_files '.*(\.dockerfile|Dockerfile)$'; then
6969
TARGETS+=("docker")
7070
fi
71-
if match_files '.github/(actions|workflows)/.*\.(yaml|yml)$'; then
71+
if match_files '(action\.(yaml|yml))|(\.github/(actions|workflows)/.*\.(yaml|yml))$'; then
7272
TARGETS+=("github" "ratchet")
73+
RATCHET_FILES="$(find_files '(action\.(yaml|yml))|(\.github/(actions|workflows)/.*\.(yaml|yml))$' | tr '\n' ' ')"
74+
echo "::debug::Found ratchetable files: ${RATCHET_FILES}"
75+
echo "ratchet-files=${RATCHET_FILES}" >> "${GITHUB_OUTPUT}"
7376
fi
7477
if match_files 'go.mod$'; then
7578
TARGETS+=("go")
@@ -157,7 +160,7 @@ jobs:
157160
${{ matrix.lint-target == 'ratchet' }}
158161
uses: 'sethvargo/ratchet@main' # ratchet:exclude
159162
with:
160-
files: './.github/actions/**/*.yml ./.github/workflows/*.yml'
163+
files: '${{ needs.init.outputs.ratchet-files }}'
161164

162165
- name: 'Lint (Shell)'
163166
if: |-

0 commit comments

Comments
 (0)