Skip to content
Open
Show file tree
Hide file tree
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
39 changes: 0 additions & 39 deletions .github/actions/change-detection/action.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/actions/paths-filter/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Paths filter
description: Detects whether any file changed in the current PR matches at least one of the supplied glob patterns.

inputs:
patterns:
description: |
Newline-separated list of glob patterns to match against the changed files
in the PR. Patterns use bash glob syntax (e.g. `path/**`, `path/file.ext`).
required: true

outputs:
changed:
description: '`''true''` if at least one changed file matches one of the patterns, otherwise `''false''`. Always `''true''` on non-pull_request events.'
value: ${{ steps.filter.outputs.changed }}

runs:
using: composite
steps:
- name: Match changed files against patterns
id: filter
shell: bash
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PATTERNS: ${{ inputs.patterns }}
run: |
set -euo pipefail

if [[ "${EVENT_NAME}" != "pull_request" && "${EVENT_NAME}" != "pull_request_target" ]]; then
echo "Event '${EVENT_NAME}' is not a pull_request; defaulting changed=true."
echo "changed=true" >> "${GITHUB_OUTPUT}"
exit 0
fi

mapfile -t patterns < <(printf '%s\n' "${PATTERNS}" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g' | grep -v '^$' || true)
if [[ ${#patterns[@]} -eq 0 ]]; then
echo "No patterns supplied; nothing to match."
echo "changed=false" >> "${GITHUB_OUTPUT}"
exit 0
fi

echo "Patterns:"
printf ' %s\n' "${patterns[@]}"

mapfile -t changed_files < <(gh api --paginate "/repos/${REPO}/pulls/${PR_NUMBER}/files" --jq '.[].filename')
echo "Changed files (${#changed_files[@]}):"
printf ' %s\n' "${changed_files[@]:-(none)}"

shopt -s extglob
any_match=false
for file in "${changed_files[@]:-}"; do
[[ -z "${file}" ]] && continue
for pattern in "${patterns[@]}"; do
if [[ "${file}" == ${pattern} ]]; then
echo "Match: ${file} ~ ${pattern}"
any_match=true
break
fi
done
done

echo "changed=${any_match}" >> "${GITHUB_OUTPUT}"
13 changes: 8 additions & 5 deletions .github/workflows/metadata-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
docs: ${{ steps.detect-changes.outputs.docs }}
docs: ${{ steps.detect-changes.outputs.changed }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
persist-credentials: true # required to get more history in the changed-files action
fetch-depth: 2
persist-credentials: false
- name: Detect changes
id: detect-changes
uses: ./.github/actions/change-detection
uses: ./.github/actions/paths-filter
with:
self: .github/workflows/metadata-lint.yml
patterns: |
.github/workflows/metadata-lint.yml
.github/actions/paths-filter/**
docusaurus/docs/**

lint-metadata:
needs: detect-changes
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ jobs:
permissions:
pull-requests: read
outputs:
docs: ${{ steps.filter.outputs.docs }}
docs: ${{ steps.filter.outputs.changed }}
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/paths-filter
id: filter
with:
filters: |
docs:
- '.github/workflows/deploy-to-developer-portal-dev.yml'
- '.github/workflows/deploy-to-developer-portal-prod.yml'
- '.github/workflows/test-build.yml'
- 'docusaurus/**'
- 'package-lock.json'
patterns: |
.github/workflows/deploy-to-developer-portal-dev.yml
.github/workflows/deploy-to-developer-portal-prod.yml
.github/workflows/test-build.yml
.github/actions/paths-filter/**
docusaurus/**
package-lock.json

build-docs:
needs: changes
Expand Down
Loading