DD 2.1: trim metadata whitespace + clear BuiltPre1978YN LookupStatus #1
Workflow file for this run
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: Generate DD reference JSON | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "references/dd/RESODataDictionary-*.xlsx" | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "references/dd/RESODataDictionary-*.xlsx" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: generate-dd-json-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout transport | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Sparse-checkout reso-tools utilities | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: RESOStandards/reso-tools | |
| ref: main | |
| path: .reso-tools | |
| sparse-checkout: | | |
| reso-certification/utils | |
| sparse-checkout-cone-mode: false | |
| - name: Setup Node 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Detect DD versions present | |
| id: versions | |
| run: | | |
| set -euo pipefail | |
| versions="" | |
| for xlsx in references/dd/RESODataDictionary-*.xlsx; do | |
| [ -f "$xlsx" ] || continue | |
| v="$(basename "$xlsx" | sed -E 's/^RESODataDictionary-(.+)\.xlsx$/\1/')" | |
| versions="${versions} ${v}" | |
| done | |
| versions="$(echo "${versions}" | xargs)" | |
| if [ -z "${versions}" ]; then | |
| echo "No RESODataDictionary-*.xlsx files found under references/dd/" | |
| exit 1 | |
| fi | |
| echo "list=${versions}" >> "$GITHUB_OUTPUT" | |
| echo "Detected versions: ${versions}" | |
| - name: Generate reference-metadata JSON per version | |
| run: | | |
| set -euo pipefail | |
| mkdir -p references/dd/json | |
| for v in ${{ steps.versions.outputs.list }}; do | |
| xlsx="references/dd/RESODataDictionary-${v}.xlsx" | |
| out="references/dd/json/dd-${v}.json" | |
| echo "Generating ${out} from ${xlsx}" | |
| node .reso-tools/reso-certification/utils/generate-reference-metadata.js \ | |
| "${xlsx}" "${v}" "${out}" | |
| done | |
| - name: Run DD reference fitness checks | |
| run: | | |
| set -euo pipefail | |
| files="" | |
| for v in ${{ steps.versions.outputs.list }}; do | |
| files="${files} references/dd/json/dd-${v}.json" | |
| done | |
| node .reso-tools/reso-certification/utils/check-dd-reference-fitness.js ${files} | |
| - name: Diff summary (PR only) | |
| if: github.event_name == 'pull_request' | |
| id: diff | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "## DD reference JSON regeneration" | |
| echo | |
| echo "Triggered by changes under \`references/dd/RESODataDictionary-*.xlsx\`." | |
| echo | |
| echo "### Versions regenerated" | |
| for v in ${{ steps.versions.outputs.list }}; do | |
| echo "- \`dd-${v}.json\`" | |
| done | |
| echo | |
| echo "### Fitness checks" | |
| echo "All per-file and cross-version checks ran in the previous step. Re-run logs above for details." | |
| echo | |
| echo "### Per-version counts" | |
| echo | |
| echo "| version | resources | fields | lookups |" | |
| echo "|---------|-----------|--------|---------|" | |
| for v in ${{ steps.versions.outputs.list }}; do | |
| file="references/dd/json/dd-${v}.json" | |
| r=$(node -e "const j=require('./'+process.argv[1]);console.log((j.resources||[]).length)" "${file}") | |
| f=$(node -e "const j=require('./'+process.argv[1]);console.log((j.fields||[]).length)" "${file}") | |
| l=$(node -e "const j=require('./'+process.argv[1]);console.log((j.lookups||[]).length)" "${file}") | |
| echo "| ${v} | ${r} | ${f} | ${l} |" | |
| done | |
| echo | |
| echo "_Regenerated by \`generate-dd-json\` workflow against \`reso-tools@main\` utilities._" | |
| } > /tmp/pr-comment.md | |
| { | |
| echo "comment<<EOF" | |
| cat /tmp/pr-comment.md | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Post PR comment | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const body = `${{ steps.diff.outputs.comment }}`; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); | |
| - name: Commit regenerated JSON back to main (push only) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add references/dd/json/dd-*.json | |
| if git diff --cached --quiet; then | |
| echo "No JSON changes to commit." | |
| exit 0 | |
| fi | |
| versions="${{ steps.versions.outputs.list }}" | |
| git commit -m "Regenerate DD reference JSON (${versions}) [skip ci]" | |
| git push origin HEAD:main |