Skip to content

Commit 35ba344

Browse files
committed
Add PCD automation workflows
1 parent 3f6fde5 commit 35ba344

2 files changed

Lines changed: 200 additions & 0 deletions

File tree

.github/workflows/pcd-cleanup.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: PCD README cleanup
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *'
6+
workflow_dispatch:
7+
inputs:
8+
force:
9+
description: "Clear the PCD-INFO block immediately, even if End 2 has not passed (useful if a PCD is cancelled or for testing)."
10+
required: false
11+
type: boolean
12+
default: false
13+
14+
jobs:
15+
check:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
expired: ${{ steps.check.outputs.expired }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Determine if PCD-INFO block is expired
23+
id: check
24+
env:
25+
FORCE: ${{ inputs.force }}
26+
run: |
27+
set -e
28+
29+
if [[ "$FORCE" == "true" ]]; then
30+
echo "force=true; bypassing date check."
31+
echo "expired=true" >> "$GITHUB_OUTPUT"
32+
exit 0
33+
fi
34+
35+
if [[ ! -f README.md ]]; then
36+
echo "README.md not found; nothing to check."
37+
echo "expired=false" >> "$GITHUB_OUTPUT"
38+
exit 0
39+
fi
40+
41+
if ! grep -q '<!-- PCD-INFO:START -->' README.md; then
42+
echo "No PCD-INFO markers in README; nothing to clean up."
43+
echo "expired=false" >> "$GITHUB_OUTPUT"
44+
exit 0
45+
fi
46+
47+
# Extract "no later than YYYY-MM-DD" date from the PCD-INFO block.
48+
END_2=$(awk '/<!-- PCD-INFO:START -->/,/<!-- PCD-INFO:END -->/' README.md \
49+
| grep -oE 'no later than [0-9]{4}-[0-9]{2}-[0-9]{2}' \
50+
| head -1 \
51+
| sed 's/^no later than //')
52+
53+
if [[ -z "$END_2" ]]; then
54+
echo "PCD-INFO block present but no 'no later than YYYY-MM-DD' date found; not clearing."
55+
echo "expired=false" >> "$GITHUB_OUTPUT"
56+
exit 0
57+
fi
58+
59+
TODAY=$(date -u +%Y-%m-%d)
60+
echo "End 2 date: $END_2"
61+
echo "Today (UTC): $TODAY"
62+
63+
# String comparison works for ISO-8601 dates (YYYY-MM-DD).
64+
if [[ "$TODAY" > "$END_2" ]]; then
65+
echo "Today is past End 2; PCD-INFO block is expired."
66+
echo "expired=true" >> "$GITHUB_OUTPUT"
67+
else
68+
echo "Today is on or before End 2; PCD-INFO block is still active."
69+
echo "expired=false" >> "$GITHUB_OUTPUT"
70+
fi
71+
72+
clear:
73+
needs: check
74+
if: needs.check.outputs.expired == 'true'
75+
permissions:
76+
contents: write
77+
pull-requests: write
78+
uses: SMPTE/html-pub/.github/workflows/pcd-cleanup-reusable.yml@main

.github/workflows/pcd-update.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: PCD README update
2+
3+
on:
4+
repository_dispatch:
5+
types: [pcd-published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: "Release tag on the private repo, e.g. 20260319-cd"
10+
required: true
11+
type: string
12+
private_repo:
13+
description: "Private repo, e.g. SMPTE/tst123-4-private"
14+
required: true
15+
type: string
16+
end_1:
17+
description: "Review ends no earlier than (YYYY-MM-DD)"
18+
required: true
19+
type: string
20+
end_2:
21+
description: "Review ends no later than (YYYY-MM-DD)"
22+
required: true
23+
type: string
24+
message:
25+
description: "Details/marketing message (multi-line allowed)"
26+
required: false
27+
type: string
28+
default: ""
29+
30+
jobs:
31+
resolve:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
tag: ${{ steps.fields.outputs.tag }}
35+
release_url: ${{ steps.fields.outputs.release_url }}
36+
doc_url: ${{ steps.fields.outputs.doc_url }}
37+
private_repo: ${{ steps.fields.outputs.private_repo }}
38+
private_repo_name: ${{ steps.fields.outputs.private_repo_name }}
39+
public_repo: ${{ steps.fields.outputs.public_repo }}
40+
public_repo_name: ${{ steps.fields.outputs.public_repo_name }}
41+
end_1: ${{ steps.fields.outputs.end_1 }}
42+
end_2: ${{ steps.fields.outputs.end_2 }}
43+
message: ${{ steps.fields.outputs.message }}
44+
steps:
45+
- name: Derive fields
46+
id: fields
47+
env:
48+
EVENT_NAME: ${{ github.event_name }}
49+
PAYLOAD_TAG: ${{ github.event.client_payload.tag }}
50+
PAYLOAD_RELEASE_URL: ${{ github.event.client_payload.release_url }}
51+
PAYLOAD_DOC_URL: ${{ github.event.client_payload.doc_url }}
52+
PAYLOAD_PRIVATE_REPO: ${{ github.event.client_payload.private_repo }}
53+
PAYLOAD_PUBLIC_REPO: ${{ github.event.client_payload.public_repo }}
54+
PAYLOAD_END_1: ${{ github.event.client_payload.end_1 }}
55+
PAYLOAD_END_2: ${{ github.event.client_payload.end_2 }}
56+
PAYLOAD_MESSAGE: ${{ github.event.client_payload.message }}
57+
INPUT_TAG: ${{ inputs.tag }}
58+
INPUT_PRIVATE_REPO: ${{ inputs.private_repo }}
59+
INPUT_END_1: ${{ inputs.end_1 }}
60+
INPUT_END_2: ${{ inputs.end_2 }}
61+
INPUT_MESSAGE: ${{ inputs.message }}
62+
GITHUB_REPO: ${{ github.repository }}
63+
run: |
64+
if [[ "$EVENT_NAME" == "repository_dispatch" ]]; then
65+
TAG="$PAYLOAD_TAG"
66+
RELEASE_URL="$PAYLOAD_RELEASE_URL"
67+
DOC_URL="$PAYLOAD_DOC_URL"
68+
PRIVATE_REPO="$PAYLOAD_PRIVATE_REPO"
69+
PUBLIC_REPO="$PAYLOAD_PUBLIC_REPO"
70+
END_1="$PAYLOAD_END_1"
71+
END_2="$PAYLOAD_END_2"
72+
MESSAGE="$PAYLOAD_MESSAGE"
73+
else
74+
TAG="$INPUT_TAG"
75+
PRIVATE_REPO="$INPUT_PRIVATE_REPO"
76+
PUBLIC_REPO="$GITHUB_REPO"
77+
RELEASE_URL="https://github.com/${PRIVATE_REPO}/releases/tag/${TAG}"
78+
DOC_URL="https://doc.smpte-doc.org/${PRIVATE_REPO#*/}/${TAG}/"
79+
END_1="$INPUT_END_1"
80+
END_2="$INPUT_END_2"
81+
MESSAGE="$INPUT_MESSAGE"
82+
fi
83+
PRIVATE_REPO_NAME="${PRIVATE_REPO#*/}"
84+
PUBLIC_REPO_NAME="${PUBLIC_REPO#*/}"
85+
86+
{
87+
echo "tag=$TAG"
88+
echo "release_url=$RELEASE_URL"
89+
echo "doc_url=$DOC_URL"
90+
echo "private_repo=$PRIVATE_REPO"
91+
echo "private_repo_name=$PRIVATE_REPO_NAME"
92+
echo "public_repo=$PUBLIC_REPO"
93+
echo "public_repo_name=$PUBLIC_REPO_NAME"
94+
echo "end_1=$END_1"
95+
echo "end_2=$END_2"
96+
} >> "$GITHUB_OUTPUT"
97+
98+
# Multi-line message uses GITHUB_OUTPUT heredoc syntax
99+
DELIMITER="EOF_$(date +%s)_$$"
100+
{
101+
echo "message<<${DELIMITER}"
102+
printf '%s\n' "$MESSAGE"
103+
echo "${DELIMITER}"
104+
} >> "$GITHUB_OUTPUT"
105+
106+
update:
107+
needs: resolve
108+
permissions:
109+
contents: write
110+
pull-requests: write
111+
uses: SMPTE/html-pub/.github/workflows/pcd-update-reusable.yml@main
112+
with:
113+
tag: ${{ needs.resolve.outputs.tag }}
114+
release_url: ${{ needs.resolve.outputs.release_url }}
115+
doc_url: ${{ needs.resolve.outputs.doc_url }}
116+
private_repo: ${{ needs.resolve.outputs.private_repo }}
117+
private_repo_name: ${{ needs.resolve.outputs.private_repo_name }}
118+
public_repo: ${{ needs.resolve.outputs.public_repo }}
119+
public_repo_name: ${{ needs.resolve.outputs.public_repo_name }}
120+
end_1: ${{ needs.resolve.outputs.end_1 }}
121+
end_2: ${{ needs.resolve.outputs.end_2 }}
122+
message: ${{ needs.resolve.outputs.message }}

0 commit comments

Comments
 (0)