Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing config.json and replacing with workflow env variables. #14

Merged
merged 1 commit into from
Sep 26, 2023
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
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