diff --git a/.github/workflows/compliance-workflow.yml b/.github/workflows/compliance-workflow.yml new file mode 100644 index 00000000..0e869693 --- /dev/null +++ b/.github/workflows/compliance-workflow.yml @@ -0,0 +1,11 @@ +name: Compliance Workflow + +on: + workflow_dispatch: + schedule: + - cron: "0 1 * * 1-5" + +jobs: + CyDig-Compliance-Workflow: + uses: Omegapoint/cydig-reusable-workflows/.github/workflows/compliance-template.yml@main + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d99ef919..c309cbf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,17 +12,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Update URL variables - run: | - (Get-Content '${{ github.workspace }}/src/config.json') | Foreach-Object { - $_ -replace '###urlupdate###', '${{vars.URLUPDATECOMPLIANCESTATE}}' ` - -replace '###urlread###', '${{vars.URLREADTOREADME}}' ` - -replace '###urldashboard###', '${{vars.URLDASHBOARD}}' ` - -replace '###readtoreadmeaccesskey###', '${{secrets.READTOREADMEACCESSKEY}}' ` - - } | Set-Content '${{ github.workspace }}/config.json' - shell: pwsh - - name: Install dependencies and build run: npm ci && npm run build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13866e96..54a489dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,17 +14,6 @@ jobs: uses: actions/checkout@v3 - name: Setup node uses: actions/setup-node@v3 - # - name: Update URL variables - # run: | - # (Get-Content '${{ github.workspace }}/src/config.json') | Foreach-Object { - # $_ -replace '###urlupdate###', '${{vars.URLUPDATECOMPLIANCESTATE}}' ` - # -replace '###urlread###', '${{vars.URLREADTOREADME}}' ` - # -replace '###urldashboard###', '${{vars.URLDASHBOARD}}' ` - # -replace '###readtoreadmeaccesskey###', '${{secrets.READTOREADMEACCESSKEY}}' ` - - # } | Set-Content '${{ github.workspace }}/config.json' - # shell: pwsh - - name: Install dependencies run: npm ci - name: Run tests diff --git a/src/config.json b/src/config.json deleted file mode 100644 index 7b4e91d1..00000000 --- a/src/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "urlUpdate": "###urlupdate###", - "urlRead": "###urlread###", - "urlDashboard": "###urldashboard###", - "readToReadMeKeyAcessKey": "###readtoreadmeaccesskey###" -} diff --git a/src/lib/ComplianceStateService.ts b/src/lib/ComplianceStateService.ts index e5433653..630d300a 100644 --- a/src/lib/ComplianceStateService.ts +++ b/src/lib/ComplianceStateService.ts @@ -1,9 +1,9 @@ import { BodyBuilder } from './BodyBuilder'; import axios from 'axios'; -import config from '../config.json'; import { ResponseBody } from './ResponseBody'; import * as fs from 'fs'; import * as path from 'path'; +import * as core from '@actions/core'; export class ComplianceStateService { public async createAndSendComplianceState( @@ -13,7 +13,7 @@ export class ComplianceStateService { subscriptionId: string ): Promise { // POST-request to Azure function - const urlUpdate: string = config.urlUpdate; + const urlUpdate: string = process.env.urlUpdate || ''; const bodyBuilder: BodyBuilder = new BodyBuilder(); const responseBody: ResponseBody = bodyBuilder.createBody( teamName, @@ -35,6 +35,7 @@ export class ComplianceStateService { //Remove this console.log console.log('Debug: ' + outputFilePath); fs.writeFileSync(outputFilePath, urls, 'utf-8'); + core.setOutput("readme-badges", urls); console.log(urls); }) // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/lib/UrlBuilder.ts b/src/lib/UrlBuilder.ts index 0bf6bcca..b59ce3ca 100644 --- a/src/lib/UrlBuilder.ts +++ b/src/lib/UrlBuilder.ts @@ -1,4 +1,3 @@ -import config from '../config.json'; export class UrlBuilder { static createUrl( @@ -11,9 +10,9 @@ export class UrlBuilder { states: object ): string { //DonĀ“t forget to implement this as github secrets in the repository - const urlReadToReadMe: string = config.urlRead; - const urlDashboard: string = config.urlDashboard; - const readToReadMeKeyAcessKey: string = config.readToReadMeKeyAcessKey; + const urlReadToReadMe: string = process.env.urlRead || ''; + const urlDashboard: string = process.env.urlDashboard || ''; + const readToReadMeKeyAcessKey: string = process.env.readToReadMeKeyAcessKey || ''; let urls: string = ''; let encodedURL: string; let singleBadgeURL: string;