Skip to content
This repository was archived by the owner on Mar 30, 2023. It is now read-only.

Commit c3c17d4

Browse files
committed
initial commit
0 parents  commit c3c17d4

15 files changed

+3037
-0
lines changed

.github/workflows/main.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and deploy main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
DOCKER_IMAGE: ghcr.io/navikt/${{ github.repository }}:${{ github.sha }}
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Setup Node
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: "18.x"
21+
22+
- name: Install dependencies
23+
run: yarn
24+
25+
- name: Build
26+
run: yarn build
27+
28+
- name: Login to GitHub Docker Registry
29+
uses: docker/login-action@v1
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Generate Docker image tag with short sha
36+
id: dockertag
37+
run: echo "::set-output name=docker_img::ghcr.io/${{ github.repository }}:$(git rev-parse --short HEAD)"
38+
39+
- name: Build and push the Docker image
40+
uses: docker/build-push-action@v2
41+
with:
42+
context: .
43+
push: true
44+
tags: ${{ env.DOCKER_IMAGE }}
45+
46+
deploy-prod:
47+
runs-on: ubuntu-latest
48+
needs: build
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: nais/deploy/actions/deploy@v1
52+
if: github.ref == 'refs/heads/main'
53+
env:
54+
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
55+
CLUSTER: prod-gcp
56+
RESOURCE: nais.yml
57+
IMAGE: ${{ env.DOCKER_IMAGE }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM nginxinc/nginx-unprivileged:1.20-alpine
2+
3+
USER nginx
4+
WORKDIR /app
5+
6+
COPY dist/ ./
7+
COPY nginx.conf /etc/nginx/conf.d/default.conf
8+
9+
EXPOSE 8080

data/index.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import git from "simple-git";
2+
import fs from "node:fs/promises";
3+
import path from "node:path";
4+
import * as R from "remeda";
5+
6+
const GIT_ROOT = "/home/karl/git";
7+
const REPOS = [
8+
"sykmeldinger",
9+
"dinesykmeldte",
10+
"syk-dig",
11+
"syfosmmanuell",
12+
"smregistrering",
13+
];
14+
15+
async function main() {
16+
const repoDirs = await Promise.all(
17+
REPOS.map((it) => fs.readdir(path.join(GIT_ROOT, it)))
18+
);
19+
20+
await Promise.all(
21+
REPOS.map(async (it) => {
22+
const gitPath = path.join(GIT_ROOT, it);
23+
24+
const branch = (await git(gitPath).branch()).current;
25+
26+
if (!(branch === "main" || branch === "master")) {
27+
throw new Error(`${it} is not on master/main (${branch})`);
28+
}
29+
})
30+
);
31+
32+
const pkgJsons = await Promise.all(
33+
REPOS.map((it) =>
34+
fs
35+
.readFile(path.join(GIT_ROOT, it, "package.json"))
36+
.then((it) => JSON.parse(it))
37+
)
38+
);
39+
40+
const grouped = R.pipe(
41+
pkgJsons,
42+
R.flatMap((it) =>
43+
R.pipe(
44+
[...R.toPairs(it.dependencies), ...R.toPairs(it.devDependencies)],
45+
R.map((pairs) => [...pairs, it.name])
46+
)
47+
),
48+
R.groupBy((it) => it[0]),
49+
R.mapValues((it) => {
50+
if (it.length === 1) return it;
51+
return R.reduce(it, (acc, item) => {
52+
const index = acc.findIndex(itm => itm[0]+itm[1] === item[0]+item[1])
53+
if (index >= 0) {
54+
acc[index].push(item[2])
55+
return acc;
56+
}
57+
return [...acc, item];
58+
}, []);
59+
}),
60+
R.toPairs,
61+
R.sortBy((it) => it[1].length),
62+
R.reverse,
63+
);
64+
65+
await fs.writeFile("./data/result.json", JSON.stringify(grouped, null, 2));
66+
}
67+
68+
main();

0 commit comments

Comments
 (0)