-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
17,584 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Matched against repo root (asterisk) | ||
* @mishraomp @jeff-card | ||
|
||
# Matched against directories | ||
# /.github/workflows/ @mishraomp @jeff-card | ||
|
||
# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Deploy to GitHub Pages on push to main | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-deploy: | ||
name: Build and Deploy Docusaurus to GitHub Pages | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
working-directory: ./patterns | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
cache-dependency-path: patterns/package-lock.json | ||
|
||
- name: Install dependencies | ||
run: npm ci --ignore-scripts | ||
- name: Build website | ||
run: | | ||
export BASE_URL="/nr-architecture-patterns-library" && npm run build | ||
# Popular action to deploy to GitHub Pages: | ||
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# Build output to publish to the `gh-pages` branch: | ||
publish_dir: ./patterns/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Pull Request Closed | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# Clean up OpenShift when PR closed, no conditions | ||
cleanup-openshift: | ||
name: Cleanup OpenShift | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Remove OpenShift artifacts | ||
run: | | ||
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ vars.OC_SERVER }} | ||
oc project ${{ vars.OC_NAMESPACE }} | ||
# Remove old build runs, build pods and deployment pods | ||
helm uninstall ${{ github.event.repository.name }}-${{ github.event.number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Deploy to OpenShift on PR | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
pr-description-add: | ||
name: PR Description Add | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
pull-requests: write | ||
timeout-minutes: 1 | ||
steps: | ||
- uses: bcgov-nr/action-pr-description-add@v1.1.0 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
add_markdown: | | ||
--- | ||
Thanks for the PR! | ||
Deployments, as required, will be available below: | ||
- [Frontend](https://${{ github.event.repository.name }}-${{ github.event.number }}.apps.silver.devops.gov.bc.ca) | ||
builds: | ||
name: Builds | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
packages: write | ||
strategy: | ||
matrix: | ||
package: [frontend] | ||
include: | ||
- package: frontend | ||
triggers: ('patterns/') | ||
build_file: ./patterns/Dockerfile | ||
build_context: ./patterns | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: bcgov-nr/action-builder-ghcr@v2.0.1 | ||
with: | ||
package: ${{ matrix.package }} | ||
tag: pr-${{ github.event.number }} | ||
tag_fallback: test | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
triggers: ${{ matrix.triggers }} | ||
build_context: ${{ matrix.build_context }} | ||
build_file: ${{ matrix.build_file }} | ||
deploys: | ||
name: Deploys | ||
needs: [builds] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
name: Checkout | ||
- name: Deploy to OpenShift | ||
shell: bash | ||
run: | | ||
# Allow pipefail, since we could be catching oc create errors | ||
set +o pipefail | ||
# Login to OpenShift (NOTE: project command is a safeguard) | ||
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }} | ||
oc project ${{ vars.oc_namespace }} | ||
helm uninstall ${{ github.event.repository.name }}-${{ github.event.number }} || true | ||
# Deploy Helm Chart | ||
cd charts/${{ github.event.repository.name }} | ||
helm dependency update | ||
helm upgrade --install --wait --atomic ${{ github.event.repository.name }}-${{ github.event.number }} \ | ||
--set-string global.tag="pr-${{ github.event.number }}" \ | ||
--set-string global.repository="${{ github.repository }}" \ | ||
-f values.yaml --timeout 5m . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: confluence-scraper | ||
|
||
env: | ||
CONFLUENCE_USER_NAME: ${{ secrets.CONFLUENCE_USER_NAME }} | ||
CONFLUENCE_TOKEN: ${{ secrets.CONFLUENCE_TOKEN }} | ||
BASE_URL: ${{ secrets.CONFLUENCE_URL }} | ||
PAGES: "120392107,115081594,163422029,160074735" | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# * is a special character in YAML, so you have to quote this string | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
crud-confluenc: | ||
name: Get and update contents from confluence | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
working-directory: confluence-scraper | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Add Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
cache-dependency-path: patterns/package-lock.json | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: process script | ||
id: confluence_script | ||
run: | | ||
node index.js | ||
- name: Commit files # transfer the new html files back into the repository | ||
if: steps.confluence_script.outputs.updated == 'true' | ||
id: commit_push_pr | ||
run: | | ||
git config --local user.name ${{ github.actor }} | ||
git checkout -b update/confluence-content | ||
git add ../patterns | ||
git commit -m "Adding or updating the confluence pages" || echo "No changes to commit" | ||
git push origin update/confluence-content | ||
gh pr create --assignee "mishraomp" --base main --title "Updated content from confluence." --body "Updated content from confluence." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bin/** | ||
.idea | ||
.vscode | ||
*.iml | ||
my-website | ||
confluence-scraper/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# How to contribute | ||
### Not the below will update as we do some initial iterations. | ||
If you are in a developer or architect role and have experience in event-driven architecture, please create a pull request to update specific content or add new content. | ||
Please make sure to provide proper links and implementation details for review. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: v2 | ||
name: nr-architecture-patterns-library | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.1.0" | ||
|
||
dependencies: | ||
|
||
- name: component | ||
condition: frontend.enabled | ||
version: 0.2.4 | ||
repository: https://bcgov.github.io/helm-service/ | ||
alias: frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
global: | ||
repository: ~ # the repository where the images are stored. | ||
registry: ghcr.io # the registry where the images are stored. override during runtime for other registry at global level or individual level. | ||
domain: "apps.silver.devops.gov.bc.ca" # it is required, apps.silver.devops.gov.bc.ca for silver cluster | ||
openshiftImageRegistry: "image-registry.openshift-image-registry.svc:5000" | ||
tag: ~ | ||
imagestreams: | ||
enabled: true | ||
|
||
frontend: | ||
enabled: true | ||
deployment: # can be either a statefulSet or a deployment not both | ||
enabled: true | ||
containers: | ||
- name: frontend | ||
registry: '{{ .Values.global.registry }}' # example, it includes registry | ||
repository: '{{ .Values.global.repository }}' # example, it includes repository | ||
image: frontend # the exact component name, be it backend, api-1 etc... | ||
tag: '{{ .Values.global.tag }}' # example, it includes repository | ||
securityContext: | ||
capabilities: | ||
add: [ "NET_BIND_SERVICE" ] | ||
ports: | ||
- name: http | ||
containerPort: 3000 | ||
protocol: TCP | ||
- name: http2 | ||
containerPort: 3001 | ||
protocol: TCP | ||
resources: # this is optional | ||
limits: | ||
cpu: 25m | ||
memory: 50Mi | ||
requests: | ||
cpu: 10m | ||
memory: 20Mi | ||
readinessProbe: | ||
httpGet: | ||
path: /health | ||
port: 3001 | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
periodSeconds: 2 | ||
timeoutSeconds: 2 | ||
successThreshold: 1 | ||
failureThreshold: 30 | ||
livenessProbe: | ||
successThreshold: 1 | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /health | ||
port: 3001 | ||
scheme: HTTP | ||
initialDelaySeconds: 15 | ||
periodSeconds: 30 | ||
timeoutSeconds: 5 | ||
autoscaling: | ||
enabled: false | ||
|
||
service: | ||
enabled: true | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: 3000 # the container port where the application is listening on | ||
protocol: TCP | ||
route: | ||
enabled: true | ||
host: "{{ .Release.Name }}.{{ .Values.global.domain }}" | ||
targetPort: http # look at line#164 refer to the name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict' | ||
import {setOutput} from '@actions/core' | ||
const fs = require('fs'); | ||
const fs_promises = require('fs').promises; | ||
const TurndownService = require('turndown'); | ||
const turndownService = new TurndownService(); | ||
|
||
const http = require('https'); | ||
const server = http.createServer(); | ||
server.listen(3002); // just to make the process does not exit. | ||
const axios = require('axios').default; | ||
const BASE_URL = process.env.BASE_URL; | ||
console.log(BASE_URL); | ||
const PAGE_ID_LIST = process.env.PAGES?.split(','); // expected to be comma separated page ids. | ||
async function processPageIdList() { | ||
const options = { | ||
auth: { | ||
username: process.env.CONFLUENCE_USER_NAME, | ||
password: process.env.CONFLUENCE_TOKEN | ||
} | ||
}; | ||
let i=1; | ||
for (const page_id of PAGE_ID_LIST) { | ||
try { | ||
const sideBar = `---\nsidebar_position: ${i++}\n---\n`; | ||
const response = await axios.get(`${BASE_URL}/rest/api/content/${page_id}?expand=body.storage`, options); | ||
const folderPath = `../patterns/docs/${response.data.title}`; | ||
const filePath = `${folderPath}/data.json`; | ||
if (fs.existsSync(filePath)) { | ||
const fileData = await fs_promises.readFile(filePath,'utf-8'); | ||
if (fileData !== JSON.stringify(response.data)) { | ||
await fs_promises.writeFile(filePath, JSON.stringify(response?.data)); | ||
const markdown=turndownService.turndown(response?.data?.body?.storage?.value); | ||
await fs_promises.writeFile(folderPath + `/${response.data.title}.md`, sideBar+markdown); | ||
setOutput('updated', true); | ||
}else{ | ||
console.info('It is already the latest version', page_id); | ||
setOutput('updated', false); | ||
} | ||
} else { | ||
fs.mkdirSync(folderPath, { recursive: true }); | ||
await fs_promises.writeFile(filePath, JSON.stringify(response?.data)); | ||
const markdown=turndownService.turndown(response?.data?.body?.storage?.value); | ||
await fs_promises.writeFile(folderPath + `/${response.data.title}.md`, sideBar+markdown); | ||
setOutput('updated', true); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
processPageIdList().then(() => { | ||
console.info('process completed.'); | ||
process.exit(0); | ||
}).catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.