Skip to content

Commit 8094604

Browse files
ruban72claude
andauthored
Add auto-generated state-event model and SVG diagram with GitHub Page… (#6332)
* Add auto-generated state-event model and SVG diagram with GitHub Pages publishing Introduces scripts to parse CCD definition JSON files into a structured state-event model, enrich it with resolved state transitions from Java handlers and BPMN workflows, and generate an SVG diagram. Includes a GitHub Actions workflow to publish the SVG and model JSON to GitHub Pages on push to master and weekly on Monday mornings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix ESLint no-unused-vars errors in state-event scripts Remove unused variables: trunc, SEP_H, wcStart, extraH, envelopeX, envelopeY, ev (loop var), dir, and handlerPkg. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Exclude state-event scripts from SonarQube analysis These are build/documentation utility scripts, not application code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move workflow permissions to job level for least-privilege security Build job only needs contents:read. Deploy job already had its own pages:write and id-token:write scoped at job level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * DTSCCI-4116: Publish pages in github * Add pull_request and workflow_dispatch triggers to state-event workflow Enables the workflow to run on PRs (build only, no deploy) and to be triggered manually. Also adds main branch alongside master. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Allow GitHub Pages deployment from PR branches Removes the pull_request guard on deploy-pages so the state-event model can be previewed before merging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Restrict Pages deploy to non-PR events, add downloadable artifacts PR branches cannot deploy to the github-pages environment due to protection rules. The deploy step is now guarded. A separate upload-artifact step provides downloadable SVG/JSON from any PR run. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bf380a2 commit 8094604

File tree

6 files changed

+1355
-1
lines changed

6 files changed

+1355
-1
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish State-Event Model to GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- master
8+
- main
9+
push:
10+
branches:
11+
- master
12+
- main
13+
schedule:
14+
- cron: '0 6 * * 1' # Every Monday at 6am UTC — catches changes in civil-service / civil-camunda-bpmn-definition
15+
16+
jobs:
17+
build-state-event-model:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
24+
with:
25+
path: civil-ccd-definition
26+
27+
- name: Checkout civil-service
28+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
29+
with:
30+
repository: hmcts/civil-service
31+
path: civil-service
32+
33+
- name: Checkout civil-camunda-bpmn-definition
34+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
35+
with:
36+
repository: hmcts/civil-camunda-bpmn-definition
37+
path: civil-camunda-bpmn-definition
38+
39+
- name: Use Node.js 24
40+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
41+
with:
42+
node-version: 24
43+
44+
- name: Install dependencies
45+
working-directory: civil-ccd-definition
46+
env:
47+
YARN_ENABLE_SCRIPTS: "false"
48+
run: yarn install --frozen-lockfile
49+
50+
- name: Generate state-event model
51+
working-directory: civil-ccd-definition
52+
run: yarn generate:state-event-model
53+
54+
- name: Enrich model with resolved state transitions
55+
working-directory: civil-ccd-definition
56+
run: >
57+
node bin/utils/enrich-state-event-model.js
58+
build/state-event-model.json
59+
../civil-service
60+
../civil-camunda-bpmn-definition
61+
62+
- name: Generate state-event SVG diagram
63+
working-directory: civil-ccd-definition
64+
run: node bin/utils/generate-state-event-svg.js ../civil-service
65+
66+
- name: Prepare output
67+
run: |
68+
mkdir -p pages
69+
cp civil-ccd-definition/build/state-event-model.svg pages/state-event-model.svg
70+
cp civil-ccd-definition/build/state-event-model.json pages/state-event-model.json
71+
72+
- name: Upload build artifacts
73+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
74+
with:
75+
name: state-event-model
76+
path: pages/
77+
78+
- name: Upload Pages artifact
79+
if: github.event_name != 'pull_request'
80+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
81+
with:
82+
path: pages
83+
84+
deploy-pages:
85+
if: github.event_name != 'pull_request'
86+
needs: build-state-event-model
87+
runs-on: ubuntu-latest
88+
permissions:
89+
pages: write
90+
id-token: write
91+
environment:
92+
name: github-pages
93+
url: ${{ steps.deployment.outputs.page_url }}
94+
steps:
95+
- name: Deploy to GitHub Pages
96+
id: deployment
97+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac2227cb83f # v4

0 commit comments

Comments
 (0)