@@ -11,6 +11,15 @@ inputs:
1111 required : true
1212 GITHUB_TOKEN :
1313 required : true
14+ OFFICIAL_SUBMODULE_PATH :
15+ required : false
16+ default : tooling
17+ OFFICIAL_SUBMODULE_URL :
18+ required : false
19+ default : https://github.com/SMPTE/html-pub.git
20+ OFFICIAL_SUBMODULE_BRANCH :
21+ required : false
22+ default : main
1423
1524runs :
1625 using : " composite"
2029 shell : bash
2130 run : cmp ${GITHUB_ACTION_PATH}/../.github/workflows/main.yml .github/workflows/main.yml
2231
32+ - name : Enforce official submodule lock
33+ shell : bash
34+ env :
35+ SUB_PATH : ${{ inputs.OFFICIAL_SUBMODULE_PATH }}
36+ OFFICIAL_URL : ${{ inputs.OFFICIAL_SUBMODULE_URL }}
37+ OFFICIAL_BRANCH : ${{ inputs.OFFICIAL_SUBMODULE_BRANCH }}
38+ run : |
39+ set -euo pipefail
40+
41+ if [[ -z "${SUB_PATH:-}" ]]; then
42+ echo "ERROR: SUB_PATH is empty"; exit 1
43+ fi
44+
45+ if [[ ! -f ".gitmodules" ]]; then
46+ echo "ERROR: .gitmodules not found. This repository must declare the '${SUB_PATH}' submodule."
47+ exit 1
48+ fi
49+
50+ URL_IN_MODULES=$(git config -f .gitmodules --get "submodule.${SUB_PATH}.url" || true)
51+ if [[ "$URL_IN_MODULES" != "$OFFICIAL_URL" ]]; then
52+ echo "ERROR: ${SUB_PATH} URL in .gitmodules is '$URL_IN_MODULES' but must be '$OFFICIAL_URL'"
53+ exit 1
54+ fi
55+
56+ RECORDED_SHA=$(git ls-tree HEAD "$SUB_PATH" | awk '{print $3}')
57+ if [[ -z "${RECORDED_SHA:-}" ]]; then
58+ echo "ERROR: No submodule commit recorded for ${SUB_PATH}. Did you add and commit the submodule?"
59+ exit 1
60+ fi
61+
62+ OFFICIAL_SHA=$(git ls-remote "$OFFICIAL_URL" "refs/heads/$OFFICIAL_BRANCH" | awk '{print $1}')
63+ if [[ -z "${OFFICIAL_SHA:-}" ]]; then
64+ echo "ERROR: Could not read '$OFFICIAL_BRANCH' from '$OFFICIAL_URL'"
65+ exit 1
66+ fi
67+
68+ echo "Recorded(${SUB_PATH}): $RECORDED_SHA"
69+ echo "Official ($OFFICIAL_BRANCH): $OFFICIAL_SHA"
70+
71+ if [[ "$RECORDED_SHA" != "$OFFICIAL_SHA" ]]; then
72+ cat <<'MSG'
73+ ERROR : Submodule is not on latest official main.
74+
75+ To fix locally :
76+ git submodule update --init --remote -- "${SUB_PATH}"
77+ # or explicitly:
78+ cd "${SUB_PATH}"
79+ git fetch origin "${OFFICIAL_BRANCH}"
80+ git checkout --detach "origin/${OFFICIAL_BRANCH}"
81+ cd -
82+ git add "${SUB_PATH}"
83+ git commit -m "Bump ${SUB_PATH} to latest ${OFFICIAL_BRANCH}"
84+
85+ MSG
86+ exit 1
87+ fi
88+
2389 - name : Install vnu
2490 shell : bash
2591 run : sudo pip install html5validator==0.4.2
0 commit comments