scruffyscarf is checking folder structure #1498
This file contains hidden or 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: Submission time | |
| run: echo "Submitted at ${{ steps.current-time.outputs.readableTime }}" >> $GITHUB_STEP_SUMMARY | |
| - 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@v46 | |
| - name: Check all changed files in pull request | |
| env: | |
| ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_modified_files }} | |
| run: | | |
| BAD_FILES=() | |
| for file in ${ALL_CHANGED_FILES}; do | |
| echo "Testing: $file" | |
| if ! [[ "$file" =~ ^content/docs/$YEAR/$REPO_NAME/.*\.md$ ]]; 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):" | |
| for file in "${BAD_FILES[@]}"; do | |
| echo " $file" | |
| done | |
| exit 1 | |
| fi | |
| echo "All good!" |