Add year for 33.txt #28
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: Restrict Changes | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| concurrency: # Only one job per PR at a time | |
| group: pr-${{ github.event.pull_request.number }}-a | |
| cancel-in-progress: true # cancel any in-progress runs when a new commit is pushed | |
| jobs: | |
| check-changed-files: | |
| name: Check for Changes Outside Allowed Path | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| # Check out the PR files: | |
| - name: Check Out PR | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| fetch-depth: 1 # no need for full history | |
| # Fetch the base SHA to compare against: | |
| - name: Fetch base SHA | |
| run: | | |
| set -euo pipefail | |
| BASE_REPO='${{ github.event.pull_request.base.repo.clone_url }}' | |
| BASE_SHA='${{ github.event.pull_request.base.sha }}' | |
| git remote add base "$BASE_REPO" | |
| git fetch --no-tags --depth=1 base "$BASE_SHA" | |
| # Fail in case of changes outside of `data/birth-dates/*.txt` | |
| - name: Check Changed Files | |
| run: | | |
| set -euo pipefail | |
| BASE="${{ github.event.pull_request.base.sha }}" | |
| HEAD="${{ github.event.pull_request.head.sha }}" | |
| # List changed files between base and head: | |
| CHANGED_FILES="$(git diff --name-only "$BASE" "$HEAD")" | |
| echo -e "Changed files: \n${CHANGED_FILES}" | |
| if [[ -z "${CHANGED_FILES}" ]]; then | |
| exit 0 | |
| fi | |
| # Find any changed files not in the allowed path: | |
| DISALLOWED_FILES="$(echo "${CHANGED_FILES}" | grep -Ev '^data/birth-dates/[^/]+\.txt$' || true)" | |
| if [[ -n "${DISALLOWED_FILES}" ]]; then | |
| echo "::error::Disallowed changes detected!" | |
| echo "Disallowed changes detected:" >> "$GITHUB_STEP_SUMMARY" | |
| echo "${DISALLOWED_FILES}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Only files directly under data/birth-dates/ with .txt extension may be edited." >> "$GITHUB_STEP_SUMMARY" | |
| exit 1 | |
| fi | |
| echo "All changes are within data/birth-dates/*.txt" |