Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/scripts/run-pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT="$(pwd)"
AMENDMENTS_FILE="$ROOT/json-generation-pipeline/output/bc-amendments-combined.xml"
REVISIONS_FILE="$ROOT/json-generation-pipeline/output/bc-revisions-combined.xml"


java -jar json-generation-pipeline/tools/saxon.jar \
-xsl:json-generation-pipeline/transformation-xslt/nbc-to-canonical.xsl \
-s:json-generation-pipeline/source/nbc-2020-xml/nbc2020.xml \
-o:json-generation-pipeline/output/nbc-canonical.xml


java -jar json-generation-pipeline/tools/saxon.jar \
-xsl:json-generation-pipeline/transformation-xslt/combine-amendments.xsl \
-s:json-generation-pipeline/source/bc-amendments/amendment-list.xml \
-o:json-generation-pipeline/output/bc-amendments-combined.xml


java -jar json-generation-pipeline/tools/saxon.jar \
-xsl:json-generation-pipeline/transformation-xslt/merge-engine-v3.xsl \
-s:json-generation-pipeline/output/nbc-canonical.xml \
overlay-document="file://$AMENDMENTS_FILE" \
-o:json-generation-pipeline/output/bc-building-code.xml


java -jar json-generation-pipeline/tools/saxon.jar \
-xsl:json-generation-pipeline/transformation-xslt/combine-amendments.xsl \
-s:json-generation-pipeline/source/bc-revisions/revision-list.xml \
-o:json-generation-pipeline/output/bc-revisions-combined.xml


java -jar json-generation-pipeline/tools/saxon.jar \
-xsl:json-generation-pipeline/transformation-xslt/merge-engine-v3.xsl \
-s:json-generation-pipeline/output/bc-building-code.xml \
overlay-document="file://$REVISIONS_FILE" \
-o:json-generation-pipeline/output/bc-building-code-final.xml


java -jar json-generation-pipeline/tools/saxon.jar \
-xsl:json-generation-pipeline/transformation-xslt/canonical-to-json.xsl \
-s:json-generation-pipeline/output/bc-building-code-final.xml \
-o:json-generation-pipeline/output/bcbc-2024.json
43 changes: 43 additions & 0 deletions .github/workflows/generate-artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Generate BC Building Code Artifact

on:
workflow_dispatch: {}

jobs:
build:
# Allow run only when the workflow is dispatched from a branch
if: ${{ github.ref == 'refs/heads/develop' }}

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Run transformation pipeline
run: bash .github/scripts/run-pipeline.sh


- name: Upload combined artifact
uses: actions/upload-artifact@v4
with:
name: bc-building-code-artifact
path: |
json-generation-pipeline/output/**
bc-graphics/**
graphics/**

- name: Trigger Repo B sync
if: success()
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.REPO_B_TRIGGER_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/bcgov/HOUS-Interactive-BCBC/dispatches \
-d "{\"event_type\":\"sync-from-repo-a\",\"client_payload\":{\"branch\":\"${GITHUB_REF_NAME}\"}}"
Comment on lines +9 to +43

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

In general, fix this by adding a permissions block that restricts the GITHUB_TOKEN to the minimal required scopes. Because this workflow only needs to read the repository contents (for actions/checkout) and does not perform any GitHub write operations with GITHUB_TOKEN, we can safely set contents: read. Other steps that perform writes (the final curl call) already use a separate secret token, so they do not require additional GITHUB_TOKEN scopes.

The single best fix with no behavior change is to add a workflow-level permissions block right after the on: section in .github/workflows/generate-artifact.yml, applying to all jobs. This block should be:

permissions:
  contents: read

No imports or additional methods are needed; this is purely a YAML configuration change inside the shown workflow file.

Suggested changeset 1
.github/workflows/generate-artifact.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/generate-artifact.yml b/.github/workflows/generate-artifact.yml
--- a/.github/workflows/generate-artifact.yml
+++ b/.github/workflows/generate-artifact.yml
@@ -3,6 +3,9 @@
 on:
   workflow_dispatch: {}
 
+permissions:
+  contents: read
+
 jobs:
   build:
     # Allow run only when the workflow is dispatched from a branch
EOF
@@ -3,6 +3,9 @@
on:
workflow_dispatch: {}

permissions:
contents: read

jobs:
build:
# Allow run only when the workflow is dispatched from a branch
Copilot is powered by AI and may make mistakes. Always verify output.
Loading