Skip to content

PCD README cleanup

PCD README cleanup #45

Workflow file for this run

name: PCD README cleanup
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
force:
description: "Clear the PCD-INFO block immediately, even if End 2 has not passed (useful if a PCD is cancelled or for testing)."
required: false
type: boolean
default: false
jobs:
check:
runs-on: ubuntu-latest
outputs:
expired: ${{ steps.check.outputs.expired }}
steps:
- uses: actions/checkout@v4
- name: Determine if PCD-INFO block is expired
id: check
env:
FORCE: ${{ inputs.force }}
run: |
set -e
if [[ "$FORCE" == "true" ]]; then
echo "force=true; bypassing date check."
echo "expired=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ ! -f README.md ]]; then
echo "README.md not found; nothing to check."
echo "expired=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! grep -q '<!-- PCD-INFO:START -->' README.md; then
echo "No PCD-INFO markers in README; nothing to clean up."
echo "expired=false" >> "$GITHUB_OUTPUT"
exit 0
fi
# Extract "no later than YYYY-MM-DD" date from the PCD-INFO block.
END_2=$(awk '/<!-- PCD-INFO:START -->/,/<!-- PCD-INFO:END -->/' README.md \
| grep -oE 'no later than [0-9]{4}-[0-9]{2}-[0-9]{2}' \
| head -1 \
| sed 's/^no later than //')
if [[ -z "$END_2" ]]; then
echo "PCD-INFO block present but no 'no later than YYYY-MM-DD' date found; not clearing."
echo "expired=false" >> "$GITHUB_OUTPUT"
exit 0
fi
TODAY=$(date -u +%Y-%m-%d)
echo "End 2 date: $END_2"
echo "Today (UTC): $TODAY"
# String comparison works for ISO-8601 dates (YYYY-MM-DD).
if [[ "$TODAY" > "$END_2" ]]; then
echo "Today is past End 2; PCD-INFO block is expired."
echo "expired=true" >> "$GITHUB_OUTPUT"
else
echo "Today is on or before End 2; PCD-INFO block is still active."
echo "expired=false" >> "$GITHUB_OUTPUT"
fi
clear:
needs: check
if: needs.check.outputs.expired == 'true'
permissions:
contents: write
pull-requests: write
uses: SMPTE/html-pub/.github/workflows/pcd-cleanup-reusable.yml@main