From 41133ef5103aebbe7e079166c82f76cfc6cab4bc Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Mon, 9 Mar 2026 16:04:20 +0530 Subject: [PATCH 1/8] feat: added w3c Vc conext for opencert certificate --- packages/w3c-context/README.md | 1 + .../src/context/opencerts-context.json | 81 +++++++++++++++++++ packages/w3c-context/src/lib/index.ts | 3 + 3 files changed, 85 insertions(+) create mode 100644 packages/w3c-context/src/context/opencerts-context.json diff --git a/packages/w3c-context/README.md b/packages/w3c-context/README.md index b8ca512..e7e390a 100644 --- a/packages/w3c-context/README.md +++ b/packages/w3c-context/README.md @@ -72,6 +72,7 @@ The package includes the following pre-cached contexts: - `https://trustvc.io/context/render-method-context.json` - Render Methods - `https://trustvc.io/context/attachments-context.json` - Attachments - `https://trustvc.io/context/qrcode-context.json` - QR Code +- `https://trustvc.io/context/opencerts-context.json` - OpenCerts Certificate - `https://trustvc.io/context/bill-of-lading.json` - Bill of Lading - `https://trustvc.io/context/bill-of-lading-carrier.json` - Bill of Lading Carrier - `https://trustvc.io/context/coo.json` - Certificate of Origin diff --git a/packages/w3c-context/src/context/opencerts-context.json b/packages/w3c-context/src/context/opencerts-context.json new file mode 100644 index 0000000..2e3ae3c --- /dev/null +++ b/packages/w3c-context/src/context/opencerts-context.json @@ -0,0 +1,81 @@ +{ + "@context": { + "@version": 1.1, + "@protected": true, + "OpenCertsCertificate": { + "@id": "https://schema.opencerts.io/#OpenCertsCertificate", + "@type": "@id", + "@context": { + "@protected": true, + "name": { + "@id": "https://schema.org/name" + }, + "description": { + "@id": "https://schema.org/description" + }, + "issuedOn": { + "@id": "https://schema.org/dateIssued" + }, + "admissionDate": { + "@id": "https://schema.opencerts.io/#admissionDate" + }, + "graduationDate": { + "@id": "https://schema.opencerts.io/#graduationDate" + }, + "recipient": { + "@id": "https://schema.opencerts.io/#recipient" + }, + "nric": { + "@id": "https://schema.opencerts.io/#nric" + }, + "course": { + "@id": "https://schema.org/course" + }, + "transcript": { + "@id": "https://schema.opencerts.io/#transcript" + }, + "grade": { + "@id": "https://schema.org/grade" + }, + "courseCredit": { + "@id": "https://schema.opencerts.io/#courseCredit" + }, + "courseCode": { + "@id": "https://schema.opencerts.io/#courseCode" + }, + "examinationDate": { + "@id": "https://schema.opencerts.io/#examinationDate" + }, + "semester": { + "@id": "https://schema.opencerts.io/#semester" + }, + "additionalData": { + "@id": "https://schema.opencerts.io/#additionalData" + }, + "merit": { + "@id": "https://schema.opencerts.io/#merit" + }, + "studentId": { + "@id": "https://schema.opencerts.io/#studentId" + }, + "transcriptId": { + "@id": "https://schema.opencerts.io/#transcriptId" + }, + "certSignatories": { + "@id": "https://schema.opencerts.io/#certSignatories" + }, + "signature": { + "@id": "https://schema.opencerts.io/#signature" + }, + "position": { + "@id": "https://schema.org/jobTitle" + }, + "organisation": { + "@id": "https://schema.org/organization" + } + } + } + } +} + + diff --git a/packages/w3c-context/src/lib/index.ts b/packages/w3c-context/src/lib/index.ts index 54ae157..38a2ba8 100644 --- a/packages/w3c-context/src/lib/index.ts +++ b/packages/w3c-context/src/lib/index.ts @@ -16,6 +16,7 @@ import jwsV1 from '../context/jws-2020-v1.json'; import multikeyV1 from '../context/multikey-v1.json'; import promissoryNoteContext from '../context/promissory-note.json'; import qrCodeContext from '../context/qrcode-context.json'; +import opencertsContext from '../context/opencerts-context.json'; import renderContext from '../context/render-method-context.json'; import renderContextV2 from '../context/render-method-context-v2.json'; import statusList2021V1 from '../context/status-list-2021-v1.json'; @@ -38,6 +39,7 @@ export const RENDER_CONTEXT_URL = 'https://trustvc.io/context/render-method-cont export const RENDER_CONTEXT_V2_URL = 'https://trustvc.io/context/render-method-context-v2.json'; export const ATTACHMENTS_CONTEXT_URL = 'https://trustvc.io/context/attachments-context.json'; export const QRCODE_CONTEXT_URL = 'https://trustvc.io/context/qrcode-context.json'; +export const OPENCERTS_CONTEXT_URL = 'https://trustvc.io/context/opencerts-context.json'; export const BOL_CONTEXT_URL = 'https://trustvc.io/context/bill-of-lading.json'; export const BOLC_CONTEXT_URL = 'https://trustvc.io/context/bill-of-lading-carrier.json'; @@ -85,6 +87,7 @@ export const templateContexts: { [key: string]: Document } = { [INVOICE_CONTEXT_URL]: invoiceContext, [PROMISSORY_NOTE_CONTEXT_URL]: promissoryNoteContext, [WAREHOUSE_RECEIPT_CONTEXT_URL]: warehouseReceiptContext, + [OPENCERTS_CONTEXT_URL]: opencertsContext, }; export const CredentialContextVersion = { From 4f0bce9febb780c516dfbf90cebb304542dabaa5 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Mon, 9 Mar 2026 16:42:30 +0530 Subject: [PATCH 2/8] fix: updated the uri for schema --- .../src/context/opencerts-context.json | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/w3c-context/src/context/opencerts-context.json b/packages/w3c-context/src/context/opencerts-context.json index 2e3ae3c..ba220fd 100644 --- a/packages/w3c-context/src/context/opencerts-context.json +++ b/packages/w3c-context/src/context/opencerts-context.json @@ -3,7 +3,7 @@ "@version": 1.1, "@protected": true, "OpenCertsCertificate": { - "@id": "https://schema.opencerts.io/#OpenCertsCertificate", + "@id": "https://example.com/terms#OpenCertsCertificate", "@type": "@id", "@context": { "@protected": true, @@ -17,55 +17,55 @@ "@id": "https://schema.org/dateIssued" }, "admissionDate": { - "@id": "https://schema.opencerts.io/#admissionDate" + "@id": "https://example.com/terms#admissionDate" }, "graduationDate": { - "@id": "https://schema.opencerts.io/#graduationDate" + "@id": "https://example.com/terms#graduationDate" }, "recipient": { - "@id": "https://schema.opencerts.io/#recipient" + "@id": "https://example.com/terms#recipient" }, "nric": { - "@id": "https://schema.opencerts.io/#nric" + "@id": "https://example.com/terms#nric" }, "course": { "@id": "https://schema.org/course" }, "transcript": { - "@id": "https://schema.opencerts.io/#transcript" + "@id": "https://example.com/terms#transcript" }, "grade": { "@id": "https://schema.org/grade" }, "courseCredit": { - "@id": "https://schema.opencerts.io/#courseCredit" + "@id": "https://example.com/terms#courseCredit" }, "courseCode": { - "@id": "https://schema.opencerts.io/#courseCode" + "@id": "https://example.com/terms#courseCode" }, "examinationDate": { - "@id": "https://schema.opencerts.io/#examinationDate" + "@id": "https://example.com/terms#examinationDate" }, "semester": { - "@id": "https://schema.opencerts.io/#semester" + "@id": "https://example.com/terms#semester" }, "additionalData": { - "@id": "https://schema.opencerts.io/#additionalData" + "@id": "https://example.com/terms#additionalData" }, "merit": { - "@id": "https://schema.opencerts.io/#merit" + "@id": "https://example.com/terms#merit" }, "studentId": { - "@id": "https://schema.opencerts.io/#studentId" + "@id": "https://example.com/terms#studentId" }, "transcriptId": { - "@id": "https://schema.opencerts.io/#transcriptId" + "@id": "https://example.com/terms#transcriptId" }, "certSignatories": { - "@id": "https://schema.opencerts.io/#certSignatories" + "@id": "https://example.com/terms#certSignatories" }, "signature": { - "@id": "https://schema.opencerts.io/#signature" + "@id": "https://example.com/terms#signature" }, "position": { "@id": "https://schema.org/jobTitle" From 232773003fabd54b12c6285016fa41edc8d5dd8e Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Mon, 9 Mar 2026 17:01:22 +0530 Subject: [PATCH 3/8] fix: coderabbit issues --- .../src/context/opencerts-context.json | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/w3c-context/src/context/opencerts-context.json b/packages/w3c-context/src/context/opencerts-context.json index ba220fd..31c1ff3 100644 --- a/packages/w3c-context/src/context/opencerts-context.json +++ b/packages/w3c-context/src/context/opencerts-context.json @@ -3,7 +3,7 @@ "@version": 1.1, "@protected": true, "OpenCertsCertificate": { - "@id": "https://example.com/terms#OpenCertsCertificate", + "@id": "https://trustvc.io/terms#OpenCertsCertificate", "@type": "@id", "@context": { "@protected": true, @@ -17,61 +17,61 @@ "@id": "https://schema.org/dateIssued" }, "admissionDate": { - "@id": "https://example.com/terms#admissionDate" + "@id": "https://trustvc.io/terms#admissionDate" }, "graduationDate": { - "@id": "https://example.com/terms#graduationDate" + "@id": "https://trustvc.io/terms#graduationDate" }, "recipient": { - "@id": "https://example.com/terms#recipient" + "@id": "https://trustvc.io/terms#recipient" }, "nric": { - "@id": "https://example.com/terms#nric" + "@id": "https://trustvc.io/terms#nric" }, "course": { "@id": "https://schema.org/course" }, "transcript": { - "@id": "https://example.com/terms#transcript" + "@id": "https://trustvc.io/terms#transcript" }, "grade": { - "@id": "https://schema.org/grade" + "@id": "https://schema.org/gradeLevel" }, "courseCredit": { - "@id": "https://example.com/terms#courseCredit" + "@id": "https://trustvc.io/terms#courseCredit" }, "courseCode": { - "@id": "https://example.com/terms#courseCode" + "@id": "https://trustvc.io/terms#courseCode" }, "examinationDate": { - "@id": "https://example.com/terms#examinationDate" + "@id": "https://trustvc.io/terms#examinationDate" }, "semester": { - "@id": "https://example.com/terms#semester" + "@id": "https://trustvc.io/terms#semester" }, "additionalData": { - "@id": "https://example.com/terms#additionalData" + "@id": "https://trustvc.io/terms#additionalData" }, "merit": { - "@id": "https://example.com/terms#merit" + "@id": "https://trustvc.io/terms#merit" }, "studentId": { - "@id": "https://example.com/terms#studentId" + "@id": "https://trustvc.io/terms#studentId" }, "transcriptId": { - "@id": "https://example.com/terms#transcriptId" + "@id": "https://trustvc.io/terms#transcriptId" }, "certSignatories": { - "@id": "https://example.com/terms#certSignatories" + "@id": "https://trustvc.io/terms#certSignatories" }, "signature": { - "@id": "https://example.com/terms#signature" + "@id": "https://trustvc.io/terms#signature" }, "position": { "@id": "https://schema.org/jobTitle" }, "organisation": { - "@id": "https://schema.org/organization" + "@id": "https://schema.org/Organization" } } } From 1708f3c60eb79bf127a7c307ebe9577ca951859d Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Wed, 11 Mar 2026 15:29:43 +0530 Subject: [PATCH 4/8] feat: opencert certificate context --- .../src/context/opencerts-context.json | 98 +++++-------------- 1 file changed, 23 insertions(+), 75 deletions(-) diff --git a/packages/w3c-context/src/context/opencerts-context.json b/packages/w3c-context/src/context/opencerts-context.json index 31c1ff3..55d898b 100644 --- a/packages/w3c-context/src/context/opencerts-context.json +++ b/packages/w3c-context/src/context/opencerts-context.json @@ -2,80 +2,28 @@ "@context": { "@version": 1.1, "@protected": true, - "OpenCertsCertificate": { - "@id": "https://trustvc.io/terms#OpenCertsCertificate", - "@type": "@id", - "@context": { - "@protected": true, - "name": { - "@id": "https://schema.org/name" - }, - "description": { - "@id": "https://schema.org/description" - }, - "issuedOn": { - "@id": "https://schema.org/dateIssued" - }, - "admissionDate": { - "@id": "https://trustvc.io/terms#admissionDate" - }, - "graduationDate": { - "@id": "https://trustvc.io/terms#graduationDate" - }, - "recipient": { - "@id": "https://trustvc.io/terms#recipient" - }, - "nric": { - "@id": "https://trustvc.io/terms#nric" - }, - "course": { - "@id": "https://schema.org/course" - }, - "transcript": { - "@id": "https://trustvc.io/terms#transcript" - }, - "grade": { - "@id": "https://schema.org/gradeLevel" - }, - "courseCredit": { - "@id": "https://trustvc.io/terms#courseCredit" - }, - "courseCode": { - "@id": "https://trustvc.io/terms#courseCode" - }, - "examinationDate": { - "@id": "https://trustvc.io/terms#examinationDate" - }, - "semester": { - "@id": "https://trustvc.io/terms#semester" - }, - "additionalData": { - "@id": "https://trustvc.io/terms#additionalData" - }, - "merit": { - "@id": "https://trustvc.io/terms#merit" - }, - "studentId": { - "@id": "https://trustvc.io/terms#studentId" - }, - "transcriptId": { - "@id": "https://trustvc.io/terms#transcriptId" - }, - "certSignatories": { - "@id": "https://trustvc.io/terms#certSignatories" - }, - "signature": { - "@id": "https://trustvc.io/terms#signature" - }, - "position": { - "@id": "https://schema.org/jobTitle" - }, - "organisation": { - "@id": "https://schema.org/Organization" - } - } - } + "OpenCertsCertificate": "https://schema.opencerts.io/#OpenCertsCertificate", + "name": "https://schema.org/name", + "description": "https://schema.org/description", + "issuedOn": "https://schema.org/dateIssued", + "admissionDate": "https://schema.opencerts.io/#admissionDate", + "graduationDate": "https://schema.opencerts.io/#graduationDate", + "recipient": "https://schema.opencerts.io/#recipient", + "nric": "https://schema.opencerts.io/#nric", + "course": "https://schema.org/course", + "transcript": "https://schema.opencerts.io/#transcript", + "grade": "https://schema.org/grade", + "courseCredit": "https://schema.opencerts.io/#courseCredit", + "courseCode": "https://schema.opencerts.io/#courseCode", + "examinationDate": "https://schema.opencerts.io/#examinationDate", + "semester": "https://schema.opencerts.io/#semester", + "additionalData": "https://schema.opencerts.io/#additionalData", + "merit": "https://schema.opencerts.io/#merit", + "studentId": "https://schema.opencerts.io/#studentId", + "transcriptId": "https://schema.opencerts.io/#transcriptId", + "certSignatories": "https://schema.opencerts.io/#certSignatories", + "signature": "https://schema.opencerts.io/#signature", + "position": "https://schema.org/jobTitle", + "organisation": "https://schema.org/organization" } } - - From 248730db94ec752b62635a75e8a6f6c20651ef13 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Thu, 12 Mar 2026 12:29:05 +0530 Subject: [PATCH 5/8] fix: fix to example.com as context notdefined in schema.org --- .../src/context/opencerts-context.json | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/w3c-context/src/context/opencerts-context.json b/packages/w3c-context/src/context/opencerts-context.json index 55d898b..49b8058 100644 --- a/packages/w3c-context/src/context/opencerts-context.json +++ b/packages/w3c-context/src/context/opencerts-context.json @@ -2,28 +2,28 @@ "@context": { "@version": 1.1, "@protected": true, - "OpenCertsCertificate": "https://schema.opencerts.io/#OpenCertsCertificate", + "OpenCertsCertificate": "https://example.com/#OpenCertsCertificate", "name": "https://schema.org/name", "description": "https://schema.org/description", "issuedOn": "https://schema.org/dateIssued", - "admissionDate": "https://schema.opencerts.io/#admissionDate", - "graduationDate": "https://schema.opencerts.io/#graduationDate", - "recipient": "https://schema.opencerts.io/#recipient", - "nric": "https://schema.opencerts.io/#nric", + "admissionDate": "https://example.com/#admissionDate", + "graduationDate": "https://example.com/#graduationDate", + "recipient": "https://example.com/#recipient", + "nric": "https://example.com/#nric", "course": "https://schema.org/course", - "transcript": "https://schema.opencerts.io/#transcript", - "grade": "https://schema.org/grade", - "courseCredit": "https://schema.opencerts.io/#courseCredit", - "courseCode": "https://schema.opencerts.io/#courseCode", - "examinationDate": "https://schema.opencerts.io/#examinationDate", - "semester": "https://schema.opencerts.io/#semester", - "additionalData": "https://schema.opencerts.io/#additionalData", - "merit": "https://schema.opencerts.io/#merit", - "studentId": "https://schema.opencerts.io/#studentId", - "transcriptId": "https://schema.opencerts.io/#transcriptId", - "certSignatories": "https://schema.opencerts.io/#certSignatories", - "signature": "https://schema.opencerts.io/#signature", + "transcript": "https://example.com/#transcript", + "grade": "https://example.com/#grade", + "courseCredit": "https://example.com/#courseCredit", + "courseCode": "https://example.com/#courseCode", + "examinationDate": "https://example.com/#examinationDate", + "semester": "https://example.com/#semester", + "additionalData": "https://example.com/#additionalData", + "merit": "https://example.com/#merit", + "studentId": "https://example.com/#studentId", + "transcriptId": "https://example.com/#transcriptId", + "certSignatories": "https://example.com/#certSignatories", + "signature": "https://example.com/#signature", "position": "https://schema.org/jobTitle", - "organisation": "https://schema.org/organization" + "organisation": "https://example.com/#organisation" } } From f78dcab5181a08efbcaf9c959f7af39a29f446ab Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Fri, 13 Mar 2026 18:32:02 +0530 Subject: [PATCH 6/8] fix: renamed the file to opencerts-demo-context --- .../{opencerts-context.json => opencerts-demo-context.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/w3c-context/src/context/{opencerts-context.json => opencerts-demo-context.json} (100%) diff --git a/packages/w3c-context/src/context/opencerts-context.json b/packages/w3c-context/src/context/opencerts-demo-context.json similarity index 100% rename from packages/w3c-context/src/context/opencerts-context.json rename to packages/w3c-context/src/context/opencerts-demo-context.json From 49a525ef95b86f4856e1d3a375aba0ab25aeb049 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Fri, 27 Mar 2026 09:29:45 +0530 Subject: [PATCH 7/8] chore: update package versions to 2.0.2 and rename opencerts context file --- package-lock.json | 26 +++++++++++++------------- packages/w3c-context/src/lib/index.ts | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2a342c9..19274d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33008,13 +33008,13 @@ }, "packages/w3c": { "name": "@trustvc/w3c", - "version": "2.0.1", + "version": "2.0.2", "license": "Apache-2.0", "dependencies": { - "@trustvc/w3c-context": "^2.0.1", - "@trustvc/w3c-credential-status": "^2.0.1", - "@trustvc/w3c-issuer": "^2.0.1", - "@trustvc/w3c-vc": "^2.0.1" + "@trustvc/w3c-context": "^2.0.2", + "@trustvc/w3c-credential-status": "^2.0.2", + "@trustvc/w3c-issuer": "^2.0.2", + "@trustvc/w3c-vc": "^2.0.2" }, "engines": { "node": ">=18.x" @@ -33022,7 +33022,7 @@ }, "packages/w3c-context": { "name": "@trustvc/w3c-context", - "version": "2.0.1", + "version": "2.0.2", "license": "Apache-2.0", "dependencies": { "did-resolver": "^4.1.0", @@ -33114,11 +33114,11 @@ }, "packages/w3c-credential-status": { "name": "@trustvc/w3c-credential-status", - "version": "2.0.1", + "version": "2.0.2", "license": "Apache-2.0", "dependencies": { - "@trustvc/w3c-context": "^2.0.1", - "@trustvc/w3c-issuer": "^2.0.1", + "@trustvc/w3c-context": "^2.0.2", + "@trustvc/w3c-issuer": "^2.0.2", "base64url-universal": "^2.0.0", "pako": "^2.1.0" }, @@ -33128,7 +33128,7 @@ }, "packages/w3c-issuer": { "name": "@trustvc/w3c-issuer", - "version": "2.0.1", + "version": "2.0.2", "license": "Apache-2.0", "dependencies": { "@digitalbazaar/bls12-381-multikey": "^2.1.0", @@ -33145,7 +33145,7 @@ }, "packages/w3c-vc": { "name": "@trustvc/w3c-vc", - "version": "2.0.1", + "version": "2.0.2", "license": "Apache-2.0", "dependencies": { "@digitalbazaar/bbs-2023-cryptosuite": "^2.0.1", @@ -33154,8 +33154,8 @@ "@digitalbazaar/ecdsa-multikey": "^1.8.0", "@digitalbazaar/ecdsa-sd-2023-cryptosuite": "^3.4.1", "@mattrglobal/jsonld-signatures-bbs": "^1.2.0", - "@trustvc/w3c-credential-status": "^2.0.1", - "@trustvc/w3c-issuer": "^2.0.1", + "@trustvc/w3c-credential-status": "^2.0.2", + "@trustvc/w3c-issuer": "^2.0.2", "base64url-universal": "^2.0.0", "cbor": "^9.0.2", "did-resolver": "^4.1.0", diff --git a/packages/w3c-context/src/lib/index.ts b/packages/w3c-context/src/lib/index.ts index 38a2ba8..aabc8a9 100644 --- a/packages/w3c-context/src/lib/index.ts +++ b/packages/w3c-context/src/lib/index.ts @@ -16,7 +16,7 @@ import jwsV1 from '../context/jws-2020-v1.json'; import multikeyV1 from '../context/multikey-v1.json'; import promissoryNoteContext from '../context/promissory-note.json'; import qrCodeContext from '../context/qrcode-context.json'; -import opencertsContext from '../context/opencerts-context.json'; +import opencertsContext from '../context/opencerts-demo-context.json'; import renderContext from '../context/render-method-context.json'; import renderContextV2 from '../context/render-method-context-v2.json'; import statusList2021V1 from '../context/status-list-2021-v1.json'; From afeaf746a8ad0dc77c3df42a84997b0e924b6a74 Mon Sep 17 00:00:00 2001 From: rongquan1 Date: Mon, 27 Apr 2026 16:55:22 +0800 Subject: [PATCH 8/8] chore: update deployment script and add opencerts-demo-context to file list --- .github/workflows/deploy-context-dev.yml | 46 ++++++++++++++++++++++ .github/workflows/deploy-context-prod.yml | 48 +++++++++++++++++++++++ package.json | 1 - scripts/copy-files.sh | 21 ++++++---- 4 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/deploy-context-dev.yml create mode 100644 .github/workflows/deploy-context-prod.yml diff --git a/.github/workflows/deploy-context-dev.yml b/.github/workflows/deploy-context-dev.yml new file mode 100644 index 0000000..eaa7931 --- /dev/null +++ b/.github/workflows/deploy-context-dev.yml @@ -0,0 +1,46 @@ +name: Deploy context (Dev) + +on: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: deploy-context-dev + cancel-in-progress: false + +jobs: + build-and-deploy: + name: Build and deploy /context to CloudFront (Dev) + runs-on: ubuntu-latest + env: + S3_BUCKET: ${{ secrets.S3_BUCKET_CONTEXT_DEV }} + CF_DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build context files + run: bash scripts/copy-files.sh + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} + aws-region: ap-southeast-1 + + - name: Sync context JSON to S3 + run: | + aws s3 sync ./public/context "s3://${S3_BUCKET}/context/" \ + --delete \ + --content-type "application/json" \ + --cache-control "public, max-age=31536000, immutable" + + - name: Invalidate CloudFront /context/* + run: | + aws cloudfront create-invalidation \ + --distribution-id "${CF_DISTRIBUTION}" \ + --paths "/context/*" diff --git a/.github/workflows/deploy-context-prod.yml b/.github/workflows/deploy-context-prod.yml new file mode 100644 index 0000000..aff6c44 --- /dev/null +++ b/.github/workflows/deploy-context-prod.yml @@ -0,0 +1,48 @@ +name: Deploy context (Production) + +on: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: deploy-context-prod + cancel-in-progress: false + +jobs: + build-and-deploy: + name: Build and deploy /context to CloudFront (Production) + runs-on: ubuntu-latest + env: + S3_BUCKET: ${{ secrets.S3_BUCKET_CONTEXT_PROD }} + CF_DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_PROD }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: main + + - name: Build context files + run: bash scripts/copy-files.sh + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-southeast-1 + + - name: Sync context JSON to S3 + run: | + aws s3 sync ./public/context "s3://${S3_BUCKET}/context/" \ + --delete \ + --content-type "application/json" \ + --cache-control "public, max-age=31536000, immutable" + + - name: Invalidate CloudFront /context/* + run: | + aws cloudfront create-invalidation \ + --distribution-id "${CF_DISTRIBUTION}" \ + --paths "/context/*" diff --git a/package.json b/package.json index b4fa99d..2f0bced 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "lint": "nx run-many --target=lint", "lint:fix": "nx run-many --target=lint --fix", "build": "nx run-many --target=build", - "copy-files": "bash ./scripts/copy-files.sh", "clean": "nx clear-cache && nx run-many --target=clean", "dev": "nx run-many --target=dev", "precommit": "lint-staged", diff --git a/scripts/copy-files.sh b/scripts/copy-files.sh index ba0ce71..dee0f88 100644 --- a/scripts/copy-files.sh +++ b/scripts/copy-files.sh @@ -1,6 +1,6 @@ #!/bin/bash -### THIS SCRIPT IS NEEDED TO HOST THE CONTEXT FILES ON "https://trustvc.io/context/" THROUGH NETLIFY +### THIS SCRIPT STAGES THE CONTEXT FILES IN ./public/context FOR DEPLOYMENT TO S3 + CLOUDFRONT # Define the source and destination directories SOURCE_DIR="./packages/w3c-context/src/context" @@ -13,17 +13,24 @@ rm -rf ./public mkdir -p "$DEST_DIR" # List of files to copy -FILES=("attachments-context.json" "bill-of-lading.json" "bill-of-lading-carrier.json" "coo.json" "invoice.json" "promissory-note.json" "qrcode-context.json" "render-method-context.json" "transferable-records-context.json" "warehouse-receipt.json") +FILES=( + "attachments-context.json" + "bill-of-lading.json" + "bill-of-lading-carrier.json" + "coo.json" + "invoice.json" + "opencerts-demo-context.json" + "promissory-note.json" + "qrcode-context.json" + "render-method-context.json" + "transferable-records-context.json" + "warehouse-receipt.json" +) # Copy each file for FILE in "${FILES[@]}"; do cp "$SOURCE_DIR/$FILE" "$DEST_DIR/" done -echo "[[headers]] - for = \"/*\" - [headers.values] - Access-Control-Allow-Origin = \"*\"" > ./public/netlify.toml - # Optional: output a message when done echo "Files have been copied to $DEST_DIR"