Skip to content

Updated 54.txt

Updated 54.txt #34

name: Birthdate Check
on:
pull_request_target:
paths:
- "data/birth-dates/*.txt"
concurrency: # Only one job per PR at a time
group: pr-${{ github.event.pull_request.number }}-b
cancel-in-progress: true # cancel any in-progress runs when a new commit is pushed
permissions:
contents: read
# Wait for "Check for Changes Outside Allowed Path" to complete, then run the birthday check
jobs:
wait-for-changed-files-check:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.wait-for-changed-files-check.outputs.should_run }}
steps:
# First, wait for the check to complete successfully:
- name: Wait for "Check for Changes Outside Allowed Path" check to complete
uses: lewagon/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
check-name: "Check for Changes Outside Allowed Path"
# running-workflow-name: "Restrict Changes"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 5
allowed-conclusions: success
- name: Set output
id: wait-for-changed-files-check
run: echo "should_run=true" >> "$GITHUB_OUTPUT"
check-birthdates:
needs: wait-for-changed-files-check
if: ${{ needs.wait-for-changed-files-check.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
steps:
# Then checkout 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
# Always use the BASE branch's trusted files:
- name: Use base branch script and answer key
run: |
set -euo pipefail
BASE_SHA='${{ github.event.pull_request.base.sha }}'
git fetch --no-tags --depth=1 origin "$BASE_SHA"
git show "$BASE_SHA:.github/workflows/validate_birthdates.sh" > .github/workflows/validate_birthdates.sh
git show "$BASE_SHA:.github/workflows/birthdates" > .github/workflows/birthdates
chmod +x .github/workflows/validate_birthdates.sh
- name: Fetch PR head commit
run: |
set -euo pipefail
HEAD_SHA='${{ github.event.pull_request.head.sha }}'
HEAD_REPO='${{ github.event.pull_request.head.repo.clone_url }}'
git remote add head "$HEAD_REPO"
git fetch --no-tags --depth=1 head "$HEAD_SHA"
- name: Validate changed files
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: bash .github/workflows/validate_birthdates.sh