|
1 | | -name: Bundle CycloneDX 2.0 JSON Schemas |
| 1 | +name: Bundle CDX-2.0 |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | | - - 2.0-dev |
7 | | - - 2.0-dev-threatmodeling |
| 6 | + - 'master' |
| 7 | + - 'main' |
| 8 | + - '2.0-dev' |
8 | 9 | paths: |
9 | 10 | - '.github/workflows/bundle_2.0_schemas.yml' # self |
10 | | - - 'schema/2.0/**/*.schema.json' |
11 | 11 | - 'tools/src/main/js/bundler/**' |
| 12 | + - 'schema/2.0/cyclonedx-2.0.schema.json' |
| 13 | + - 'schema/2.0/**/*.schema.json' |
12 | 14 | workflow_dispatch: # Allows manual trigger |
13 | 15 |
|
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
14 | 20 | # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token |
15 | 21 | permissions: {} |
16 | 22 |
|
17 | 23 | jobs: |
18 | 24 | bundle-schemas: |
| 25 | + name: Bundle Schemas |
19 | 26 | runs-on: ubuntu-latest |
20 | | - |
| 27 | + timeout-minutes: 30 |
21 | 28 | permissions: |
22 | 29 | contents: write # Required to push changes |
23 | | - |
| 30 | + env: |
| 31 | + MODEL_DIR: schema/2.0/model |
| 32 | + SOURCE_FILE: schema/2.0/cyclonedx-2.0.schema.json |
| 33 | + BUNDLED_FILE: schema/2.0/cyclonedx-2.0-bundled.schema.json |
| 34 | + MINIFIED_FILE: schema/2.0/cyclonedx-2.0-bundled.min.schema.json |
24 | 35 | steps: |
25 | 36 | - name: Checkout repository |
26 | 37 | # see https://github.com/actions/checkout |
27 | 38 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
28 | 39 | with: |
29 | 40 | persist-credentials: false |
30 | | - |
31 | 41 | - name: Setup Node.js |
32 | 42 | # see https://github.com/actions/setup-node |
33 | 43 | uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 |
34 | 44 | with: |
35 | | - node-version: '20' |
36 | | - |
| 45 | + node-version: '24.x' |
37 | 46 | - name: Install dependencies |
38 | 47 | working-directory: tools/src/main/js/bundler |
39 | 48 | run: npm install |
40 | | - |
41 | 49 | - name: Bundle schemas |
42 | | - working-directory: tools/src/main/js/bundler |
43 | | - run: >- |
44 | | - node bundle-schemas.js |
45 | | - ../../../../../schema/2.0/model |
46 | | - ../../../../../schema/2.0/cyclonedx-2.0.schema.json |
47 | | -
|
| 50 | + run: | |
| 51 | + set -eux |
| 52 | + node tools/src/main/js/bundler/bundle-schemas.js \ |
| 53 | + "$MODEL_DIR" "$SOURCE_FILE" |
48 | 54 | - name: Check for changes and commit |
49 | 55 | env: |
50 | 56 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
51 | 57 | run: | |
52 | | - BUNDLED_FILE="schema/2.0/cyclonedx-2.0-bundled.schema.json" |
53 | | - MINIFIED_FILE="schema/2.0/cyclonedx-2.0-bundled.min.schema.json" |
54 | | - |
| 58 | + set -eu |
| 59 | +
|
55 | 60 | # Add both files (works for both new and modified files) |
56 | 61 | git add "$BUNDLED_FILE" "$MINIFIED_FILE" |
57 | | - |
| 62 | +
|
58 | 63 | # Check if there are staged changes |
59 | | - if git diff --staged --quiet; then |
| 64 | + if git diff --staged --quiet |
| 65 | + then |
60 | 66 | echo "No changes to bundled schemas" |
61 | 67 | else |
62 | 68 | echo "Committing bundled schema changes" |
|
0 commit comments