Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sync and update Compliance Checks
name: Sync checks and policies

on:
# Manually trigger the workflow
Expand Down Expand Up @@ -67,10 +67,22 @@ jobs:
git add -A
git diff --cached --quiet || git commit -m "chore: sync with visionBoard Checks"

- name: Clone fortSphere and import policies
run: |
git clone https://github.com/OpenPathfinder/fortSphere.git temp-fortSphere
cd temp-fortSphere
npm install
mkdir -p output
npm run export-policies
cp output/policies.json ../data/policies.json
cd ..
rm -rf temp-fortSphere

- name: Install Dependencies and update dynamic content
run: |
npm install
npm run populate-checks
npm run populate-policies

- name: Debug Git Changes
run: |
Expand Down
8 changes: 8 additions & 0 deletions data/policies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"name": "restrictRepoCreationGitHub",
"title": "Restrict Repository Creation",
"description": "This policy is designed to prevent members of a GitHub organization from creating new repositories. This includes public and private repositories.",
"technicalDetails": "This policy will set the following values for the organization(`members_allowed_repository_creation_type=none`, `members_can_create_public_repositories=false`, `members_can_create_private_repositories=false`) at the organization level."
}
]
4 changes: 4 additions & 0 deletions docs/policies/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Policies",
"position": 4
}
16 changes: 16 additions & 0 deletions docs/policies/restrictRepoCreationGitHub.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
sidebar_position: 1
id: restrictRepoCreationGitHub
title: Restrict Repository Creation
slug: /policies/restrictRepoCreationGitHub
---

<!-- DESCRIPTION:START -->
## Description
This policy is designed to prevent members of a GitHub organization from creating new repositories. This includes public and private repositories.
<!-- DESCRIPTION:END -->

<!-- TECHNICAL-DETAILS:START -->
## Technical Details
This policy will set the following values for the organization(`members_allowed_repository_creation_type=none`, `members_can_create_public_repositories=false`, `members_can_create_private_repositories=false`) at the organization level.
<!-- TECHNICAL-DETAILS:END -->
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"populate-checks": "node scripts/populate-checks.js"
"populate-checks": "node scripts/populate-checks.js",
"populate-policies": "node scripts/populate-policies.js"
},
"dependencies": {
"@docusaurus/core": "3.6.3",
Expand Down
63 changes: 63 additions & 0 deletions scripts/populate-policies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const { writeFileSync, existsSync, readFileSync } = require('fs')
const { updateOrCreateSegment } = require('@ulisesgascon/text-tags-manager')
const path = require('path')

const policies = require('../data/policies.json')
const descriptionStartTag = '<!-- DESCRIPTION:START -->'
const descriptionEndTag = '<!-- DESCRIPTION:END -->'
const technicalDetailsStartTag = '<!-- TECHNICAL-DETAILS:START -->'
const technicalDetailsEndTag = '<!-- TECHNICAL-DETAILS:END -->'

// @TODO: Move this function to a shared file
const replaceMetadata = (fileContent, metadata) => {
return fileContent.replace(/---[^]*?---/, metadata)
}

// Prepare the markdown files
policies.forEach((policy, index) => {
const metadata = `---
sidebar_position: ${index + 1}
id: ${policy.name}
title: ${policy.title}
slug: /policies/${policy.name}
---`.trim()
const descriptionContent = `## Description
${policy.description}`.trim()
const technicalDetailsContent = `## Technical Details
${policy.technicalDetails}`.trim()

let fileContent = `${metadata}

${descriptionStartTag}
${descriptionContent}
${descriptionEndTag}

${technicalDetailsStartTag}
${technicalDetailsContent}
${technicalDetailsEndTag}
`
const updateContent = (currentContent) => {
fileContent = currentContent
replaceMetadata(fileContent, metadata)
fileContent = updateOrCreateSegment({
original: fileContent,
replacementSegment: descriptionContent,
startTag: descriptionStartTag,
endTag: descriptionEndTag
})
fileContent = updateOrCreateSegment({
original: fileContent,
replacementSegment: technicalDetailsContent,
startTag: technicalDetailsStartTag,
endTag: technicalDetailsEndTag
})
}

const destination = path.join(process.cwd(), `docs/policies/${policy.name}.mdx`)
const fileExists = existsSync(destination)
if (fileExists) {
const currentFileContent = readFileSync(destination, 'utf8')
updateContent(currentFileContent)
}
writeFileSync(destination, fileContent)
})
Loading