Repository navigation
Expand file tree
/
Copy pathaction.yaml
More file actions
84 lines (80 loc) · 3.03 KB
/
Copy pathaction.yaml
File metadata and controls
84 lines (80 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: "Run Change Detection"
description: "Encapsulates checkout, detection of relevant changes, and reporting."
inputs:
checkout-path:
description: "Path to check out code to"
required: true
ref:
description: "The branch, ref, or SHA to checkout"
required: true
repo:
description: "The repository to checkout from"
required: true
base-ref:
description: "The base ref for comparison"
required: true
file-type:
description: "Predefined file type (cpp, python, cmake, jsonnet, yaml, md)"
required: false
include-globs:
description: "Custom include globs"
required: false
exclude-globs:
description: "Custom exclude globs"
required: false
head-ref:
description: "Explicit head ref (defaults to inputs.ref)"
required: false
outputs:
has_changes:
description: "Whether relevant changes were detected"
value: ${{ steps.filter.outputs.matched }}
matched_files:
description: "The list of matched files"
value: ${{ steps.filter.outputs.matched_files }}
runs:
using: "composite"
steps:
# This action is never called from a pull_request_target workflow;
# all callers use pull_request, issue_comment, workflow_dispatch, or
# workflow_call triggers. Even if it were called from
# pull_request_target, the empty sparse checkout below ensures no
# files from the ref are materialized on disk — only git objects are
# fetched — so no code from the PR is ever executed.
# codeql[actions/untrusted-checkout/medium]
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
path: ${{ inputs.checkout-path }}
ref: ${{ inputs.ref }}
repository: ${{ inputs.repo }}
persist-credentials: false
# Use empty sparse checkout so no PR files are materialized in the working
# tree — only git objects are needed for diff and ls-tree operations.
sparse-checkout-cone-mode: false
sparse-checkout: ""
- name: Detect relevant changes
id: filter
uses: Framework-R-D/action-detect-relevant-changes@6ede78eec7af8d0e271a2bd2bd8b08f8a7bc9cba # v1
with:
repo-path: ${{ inputs.checkout-path }}
base-ref: ${{ inputs.base-ref }}
head-ref: ${{ inputs.head-ref || inputs.ref }}
file-type: ${{ inputs.file-type }}
include-globs: ${{ inputs.include-globs }}
exclude-globs: ${{ inputs.exclude-globs }}
- name: Report detection outcome
shell: bash
env:
FILTER_MATCHED: ${{ steps.filter.outputs.matched }}
FILTER_MATCHED_FILES: ${{ steps.filter.outputs.matched_files }}
INPUT_FILE_TYPE: ${{ inputs.file-type }}
run: |
if [ "${FILTER_MATCHED}" != "true" ]; then
echo "::notice::No relevant changes detected for ${INPUT_FILE_TYPE:-custom globs}; job will be skipped."
else
echo "::group::Relevant files detected"
printf '%s\n' "${FILTER_MATCHED_FILES}"
echo "::endgroup::"
fi