-
Notifications
You must be signed in to change notification settings - Fork 61
50 lines (42 loc) · 1.63 KB
/
report-folder-structure.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
name: Check report folder structure
run-name: ${{ github.actor }} is checking folder structure
on:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
check-folder-structure:
runs-on: ubuntu-latest
steps:
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYYMMDD-HH
utcOffset: "+03:00"
- name: Set YEAR
run: echo "YEAR=${{ steps.current-time.outputs.year }}" >> $GITHUB_ENV
- name: Set REPO_NAME
run: echo "REPO_NAME=$(echo "${{ github.event.pull_request.head.repo.full_name }}" | awk -F / '{print $2}')" >> $GITHUB_ENV
- name: Get all changed files in pull request
id: changed-files
uses: tj-actions/changed-files@v44
- name: Check all changed files in pull request
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
BAD_FILES=()
for file in ${ALL_CHANGED_FILES}; do
echo "Testing: $file"
if ! [[ "$file" =~ ^content/docs/$YEAR/$REPO_NAME/.*\.md$ ]] && ! [[ "$file" =~ ^static/$YEAR/$REPO_NAME/ ]]; then
BAD_FILES+=("$file")
fi
done
echo ""
if [ ${#BAD_FILES[@]} -gt 0 ]; then
echo "The following files do not follow the patterns (content/docs/$YEAR/$REPO_NAME/**.md and static/$YEAR/$REPO_NAME/**):"
for file in "${BAD_FILES[@]}"; do
echo " $file"
done
exit 1
fi
echo "All good!"