dantetemplar is checking folder structure #739
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |