-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (160 loc) · 6.48 KB
/
Copy pathdetect-changed-files.yml
File metadata and controls
167 lines (160 loc) · 6.48 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: detect changed files
on:
workflow_call:
outputs:
added_or_modified:
value: ${{ jobs.filter_changes.outputs.added_or_modified }}
added_or_modified_files:
value: ${{ jobs.filter_changes.outputs.added_or_modified_files }}
css:
value: ${{ jobs.filter_changes.outputs.css }}
css_files:
value: ${{ jobs.filter_changes.outputs.css_files }}
flutter:
value: ${{ jobs.filter_changes.outputs.flutter }}
flutter_files:
value: ${{ jobs.filter_changes.outputs.flutter_files }}
github_actions:
value: ${{ jobs.filter_changes.outputs.github_actions }}
github_actions_files:
value: ${{ jobs.filter_changes.outputs.github_actions_files }}
html:
value: ${{ jobs.filter_changes.outputs.html }}
html_files:
value: ${{ jobs.filter_changes.outputs.html_files }}
markdown:
value: ${{ jobs.filter_changes.outputs.markdown }}
markdown_files:
value: ${{ jobs.filter_changes.outputs.markdown_files }}
python:
value: ${{ jobs.filter_changes.outputs.python }}
python_files:
value: ${{ jobs.filter_changes.outputs.python_files }}
rust:
value: ${{ jobs.filter_changes.outputs.rust }}
rust_files:
value: ${{ jobs.filter_changes.outputs.rust_files }}
zig:
value: ${{ jobs.filter_changes.outputs.zig }}
zig_files:
value: ${{ jobs.filter_changes.outputs.zig_files }}
jobs:
filter_changes:
name: filter changes
permissions:
pull-requests: read
runs-on: ubuntu-latest
outputs:
added_or_modified: ${{ steps.filter.outputs.added_or_modified }}
added_or_modified_files:
${{ steps.filter.outputs.added_or_modified_files }}
css: ${{ steps.filter.outputs.css }}
css_files: ${{ steps.filter.outputs.css_files }}
flutter: ${{ steps.filter.outputs.flutter }}
flutter_files: ${{ steps.filter.outputs.flutter_files }}
github_actions: ${{ steps.filter.outputs.github_actions }}
github_actions_files: ${{ steps.filter.outputs.github_actions_files }}
html: ${{ steps.filter.outputs.html }}
html_files: ${{ steps.filter.outputs.html_files }}
markdown: ${{ steps.filter.outputs.markdown }}
markdown_files: ${{ steps.filter.outputs.markdown_files }}
python: ${{ steps.filter.outputs.python }}
python_files: ${{ steps.filter.outputs.python_files }}
rust: ${{ steps.filter.outputs.rust }}
rust_files: ${{ steps.filter.outputs.rust_files }}
zig: ${{ steps.filter.outputs.zig }}
zig_files: ${{ steps.filter.outputs.zig_files }}
steps:
- name: Checkout source code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
fetch-depth: 20
persist-credentials: false
- name: Filter changed repository files
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706
id: filter
with:
list-files: shell
filters: |
added_or_modified:
- added|modified: '**'
css:
- added|modified: '**/*.css'
flutter:
- '**/*.dart'
- '**/pubspec.*'
- 'analysis_options.yaml'
github_actions:
- added|modified: .github/workflows/*.yml
- added|modified: .github/workflows/*.yaml
html:
- added|modified: '**/*.html'
markdown:
- added|modified: '**/*.md'
python:
- added|modified: '**/*.py'
- added|modified: '**/*.pyi'
rust:
- '**/*.rs'
- '**/Cargo.*'
zig:
- '**/*.zig'
- '**/*.zon'
- name: Annotate workflow run with changed file categories
env:
ADDED_OR_MODIFIED: ${{ steps.filter.outputs.added_or_modified }}
ADDED_OR_MODIFIED_FILES:
${{ steps.filter.outputs.added_or_modified_files }}
CSS: ${{ steps.filter.outputs.css }}
CSS_FILES: ${{ steps.filter.outputs.css_files }}
FLUTTER: ${{ steps.filter.outputs.flutter }}
FLUTTER_FILES: ${{ steps.filter.outputs.flutter_files }}
GH_ACTIONS: ${{ steps.filter.outputs.github_actions }}
GH_ACTIONS_FILES: ${{ steps.filter.outputs.github_actions_files }}
HTML: ${{ steps.filter.outputs.html }}
HTML_FILES: ${{ steps.filter.outputs.html_files }}
MARKDOWN: ${{ steps.filter.outputs.markdown }}
MARKDOWN_FILES: ${{ steps.filter.outputs.markdown_files }}
PYTHON: ${{ steps.filter.outputs.python }}
PYTHON_FILES: ${{ steps.filter.outputs.python_files }}
RUST: ${{ steps.filter.outputs.rust }}
RUST_FILES: ${{ steps.filter.outputs.rust_files }}
ZIG: ${{ steps.filter.outputs.zig }}
ZIG_FILES: ${{ steps.filter.outputs.zig_files }}
run: |
set -euo pipefail
append_summary() {
local label="$1"
local changed="$2"
local files="$3"
{
echo "- ${label}: ${changed}"
if [[ "${changed}" == "true" && -n "${files}" ]]; then
printf '%s\n' "${files}" | sed -e 's/^/ - `/' -e 's/$/`/'
fi
} >>"$GITHUB_STEP_SUMMARY"
}
emit_category() {
local label="$1"
local changed="$2"
local files="$3"
if [[ "${changed}" == "true" ]]; then
echo "::notice::${label} changed."
if [[ -n "${files}" ]]; then
echo "::group::${label} changed files"
printf '%s\n' "${files}"
echo "::endgroup::"
fi
fi
append_summary "${label}" "${changed}" "${files}"
}
echo "### :mag: Changed file categories" >>"$GITHUB_STEP_SUMMARY"
emit_category "Any tracked files" "${ADDED_OR_MODIFIED}" "${ADDED_OR_MODIFIED_FILES}"
emit_category "CSS" "${CSS}" "${CSS_FILES}"
emit_category "Flutter" "${FLUTTER}" "${FLUTTER_FILES}"
emit_category "GitHub Actions" "${GH_ACTIONS}" "${GH_ACTIONS_FILES}"
emit_category "HTML" "${HTML}" "${HTML_FILES}"
emit_category "Markdown" "${MARKDOWN}" "${MARKDOWN_FILES}"
emit_category "Python" "${PYTHON}" "${PYTHON_FILES}"
emit_category "Rust" "${RUST}" "${RUST_FILES}"
emit_category "Zig" "${ZIG}" "${ZIG_FILES}"