-
Notifications
You must be signed in to change notification settings - Fork 112
233 lines (200 loc) · 7.09 KB
/
check-project-update.yml
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Check Project Update PR
on:
pull_request:
paths:
- 'content/ws24/**'
workflow_dispatch:
jobs:
check-pr-title:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: check pr title starts with project id
run: |
./bin/check-project-update-pr/check-title.sh "$PR_TITLE"
- name: check project folder name convention
run: |
PID=$(bin/check-project-update-pr/extract_pid_from_pr_title.sh "$PR_TITLE")
ls content/ws24/**/$PID-*
check-disk-usage:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
needs: check-pr-title
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: check disk usage
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
PID=$(bin/check-project-update-pr/extract_pid_from_pr_title.sh "$PR_TITLE")
./bin/check-project-update-pr/disk-usage.sh $PID
get-files-in-pr:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "Download changed files list"
needs: check-pr-title
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: extract project id
id: extract_pid
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
project_id=$(bin/check-project-update-pr/extract_pid_from_pr_title.sh "$PR_TITLE")
pid_ok=$?
echo "project_id=$project_id" >> $GITHUB_OUTPUT
echo "pid_ok=$pid_ok" >> $GITHUB_OUTPUT
exit 0
- name: 'download changed files from gh api'
uses: dorny/paths-filter@v3
id: filter
with:
list-files: 'shell'
filters: |
in_project:
- 'content/**/${{ steps.extract_pid.outputs.project_id }}-*/**'
other_files:
- '!content/**/${{ steps.extract_pid.outputs.project_id }}-*/**'
with_spaces:
- '**/*\ *'
- name: create artifact dir and empty files
run: |
mkdir changed_files
touch changed_files/files-project.txt
touch changed_files/files-other.txt
touch changed_files/files-with-spaces.txt
- name: 'fail if pr contains files with spaces'
if: (steps.filter.outputs.with_spaces == 'true')
env:
all_files: ${{ steps.filter.outputs.with_spaces_files }}
run: |
echo "--------- PR contains files with spaces in their name - EXITING."
echo $all_files | tr ' ' '\n'
exit 101
- name: write changed files
if: (steps.filter.outputs.in_project == 'true')
env:
all_files: ${{ steps.filter.outputs.in_project_files }}
run: |
echo "--------- project_files:"
pr_adds_files=$(bin/check-project-update-pr/remove_deleted_files.sh $all_files)
echo $pr_adds_files | tr ' ' '\n'
echo $pr_adds_files > changed_files/files-project.txt
- name: 'files outside of project folder'
if: (steps.filter.outputs.other_files == 'true')
env:
all_files: ${{ steps.filter.outputs.other_files_files }}
run: |
echo "--------- non_project_files (may not be part of project update PR!):"
pr_adds_files=$(bin/check-project-update-pr/remove_deleted_files.sh $all_files)
echo $pr_adds_files | tr ' ' '\n'
echo $pr_adds_files > changed_files/files-other.txt
- name: list artifact files
run: |
ls -lart changed_files
echo "------------ changed_files/files-project.txt"
cat changed_files/files-project.txt | tr ' ' '\n'
echo "------------ changed_files/files-other.txt"
cat changed_files/files-other.txt | tr ' ' '\n'
- name: Upload changed-files.txt
uses: actions/upload-artifact@v4
with:
name: changed_files
path: changed_files/
retention-days: 1
check_artifact:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "look for artifact files"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: list artifact files
run: |
tree
ls -lart
echo "------------ files-project.txt"
cat files-project.txt | tr ' ' '\n'
echo "------------ files-other.txt"
cat files-other.txt | tr ' ' '\n'
check_files_in_pr:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "check for files outside of project folder"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: 'check for files outside the project folder'
run: |
FILES="$(cat files-other.txt)"
if ! [ -z "$FILES" ]; then
echo "--------- non_project_files found in PR:"
echo $FILES | tr ' ' '\n'
echo "ERROR: these files may not be changed within a project update PR!"
exit 14
else
echo "none found -> ok!"
fi
check_for_cats_download:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "check for cat template files"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: check for template cat images
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
FILES="$(cat files-project.txt)"
./bin/check-project-update-pr/check-for-cats-based-on-filenames.sh "$FILES"
check_file_name_convention:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "check file name conventions"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: check name conventions
run: |
echo "----------------"
cat files-project.txt
echo "----------------"
FILES="$(cat files-project.txt)"
./bin/check-project-update-pr/check-file-names.sh "$FILES"