Skip to content

Commit

Permalink
Merge pull request #14 from Omegapoint/feature/upload
Browse files Browse the repository at this point in the history
Removing config.json and replacing with workflow env variables.
  • Loading branch information
jonathanbokvad authored Sep 26, 2023
2 parents e1105d8 + 7bce61b commit 8ae197d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 34 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/compliance-workflow.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/config.json

This file was deleted.

5 changes: 3 additions & 2 deletions src/lib/ComplianceStateService.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -13,7 +13,7 @@ export class ComplianceStateService {
subscriptionId: string
): Promise<void> {
// 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,
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/lib/UrlBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import config from '../config.json';

export class UrlBuilder {
static createUrl(
Expand All @@ -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;
Expand Down

0 comments on commit 8ae197d

Please sign in to comment.