diff --git a/.github/scripts/run-pipeline.sh b/.github/scripts/run-pipeline.sh new file mode 100644 index 0000000..7e25fed --- /dev/null +++ b/.github/scripts/run-pipeline.sh @@ -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 \ No newline at end of file diff --git a/.github/workflows/generate-artifact.yml b/.github/workflows/generate-artifact.yml new file mode 100644 index 0000000..c714394 --- /dev/null +++ b/.github/workflows/generate-artifact.yml @@ -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}\"}}"