-
Notifications
You must be signed in to change notification settings - Fork 3
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
198 changed files
with
10,290 additions
and
2,108 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,29 @@ | ||
--- | ||
name: 💎 Epic | ||
about: En leveranse | ||
title: 'Kort leveransenavn (f.eks: Systemtilgang)' | ||
labels: 'epic' | ||
assignees: '' | ||
--- | ||
|
||
# Beskrivelse | ||
|
||
<!--- Overordnet funksjonell beskrivelse av hva som skal leveres. | ||
Hvordan fungerer det i dag? Hvordan skal det fungere nå? Etc. ---> | ||
|
||
## Definisjoner | ||
|
||
`Definisjon` - Noe som definerer hva noe er eller betyr | ||
|
||
## In scope | ||
|
||
<!--- Det vi _må_ levere som del av leveransen. ---> | ||
|
||
## Out of scope (evt. senere leveranse) | ||
|
||
<!--- Det som _ikke_ er relevant for denne leveransen eller kan vente til senere. ---> | ||
|
||
```[tasklist] | ||
# Features | ||
- [ ] Legg til features her | ||
``` |
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,63 @@ | ||
--- | ||
name: ✨ Feature | ||
about: En konkret funksjon som inngår i et produkt/leveranse (tilsvarende en User Story) | ||
title: Epic navn | Feature navn | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
# Beskrivelse | ||
|
||
<!--- Beskriv problemet/behovet som skal løses ---> | ||
|
||
## Definisjoner | ||
|
||
<!--- Om nødvendig ---> | ||
|
||
Se #parentIssue | ||
|
||
# Avklaringer | ||
|
||
<!--- Er det noe som trenger avklaring? ---> | ||
|
||
# Akseptansekriterier | ||
|
||
<!--- Rams opp hva som skal til for at featuren skal anses som løst ---> | ||
|
||
# Bilder/Tegninger | ||
|
||
<!--- Eks: Arkitekturskisser eller figma-tegninger ---> | ||
|
||
# Oppgaver/Tasks | ||
|
||
<!--- Delt opp i fagrupper ---> | ||
|
||
```[tasklist] | ||
### Trusselmodellering | ||
- [ ] Åpner denne endringen for mulige nye trusler eller misbruk? | ||
``` | ||
|
||
```[tasklist] | ||
### UX | ||
- [ ] Add a draft title or issue reference here | ||
``` | ||
|
||
```[tasklist] | ||
### Frontend | ||
- [ ] Add a draft title or issue reference here | ||
``` | ||
|
||
```[tasklist] | ||
### Backend | ||
- [ ] Add a draft title or issue reference here | ||
``` | ||
|
||
```[tasklist] | ||
### Dokumentasjon | ||
- [ ] Add a draft title or issue reference here | ||
``` | ||
|
||
```[tasklist] | ||
### Test | ||
- [ ] Add a draft title or issue reference here | ||
``` |
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,17 @@ | ||
--- | ||
name: 🛠️ Task | ||
about: 'Et konkret stykke arbeid som skal gjøres' | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
# Beskrivelse | ||
|
||
<!--- Beskriv oppgaven som skal utføres ---> | ||
|
||
# To do's | ||
|
||
<!--- Liste av ting som inngår i utførelsen ---> | ||
|
||
- [ ] Eks: Ta ut av oppvaskmaskinen |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
root = false | ||
|
||
[*] | ||
insert_final_newline = true | ||
tab_width = 2 |
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,206 @@ | ||
import { Chalk } from "chalk"; | ||
import { globby } from "globby"; | ||
import { Octokit } from "@octokit/action"; | ||
import { $, retry } from "zx"; | ||
import path from "node:path"; | ||
|
||
const c = new Chalk({ level: 3 }); | ||
|
||
const ghToken = process.env.GITHUB_TOKEN; | ||
const issueNumber = process.env.GITHUB_ISSUE_NUMBER; | ||
const projectNumberString = process.env.GITHUB_PROJECT_NUMBER; | ||
const fieldsJson = process.env.GITHUB_PROJECT_FIELDS; | ||
|
||
if (!ghToken || !issueNumber || !projectNumberString || !fieldsJson) { | ||
console.error("Missing required environment variables"); | ||
process.exit(1); | ||
} | ||
|
||
type FieldValue = | ||
| { readonly text: string } | ||
| { readonly number: number } | ||
| { readonly date: string } | ||
| { readonly singleSelectOptionId: string } | ||
| { readonly iterationId: string }; | ||
|
||
const fieldsSpec = JSON.parse(fieldsJson) as Readonly< | ||
Record<string, FieldValue> | ||
>; | ||
const projectNumber = Number.parseInt(projectNumberString, 10); | ||
const issueInfo = { | ||
issue_number: Number.parseInt(issueNumber, 10), | ||
owner: "Altinn", | ||
repo: "altinn-authorization", | ||
} as const; | ||
|
||
const github = new Octokit({ | ||
auth: ghToken, | ||
}); | ||
|
||
type FieldSpec = { | ||
readonly id: string; | ||
readonly name: string; | ||
readonly options?: readonly { | ||
readonly id: string; | ||
readonly name: string; | ||
}[]; | ||
}; | ||
|
||
type ProjectResponse = { | ||
readonly organization: { | ||
readonly repository: { | ||
readonly issue: { | ||
readonly id: string; | ||
readonly number: number; | ||
readonly title: string; | ||
}; | ||
}; | ||
readonly projectV2: { | ||
readonly id: string; | ||
readonly title: string; | ||
readonly fields: { | ||
readonly nodes: FieldSpec[]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
const info = await github.graphql<ProjectResponse>( | ||
` | ||
query($org: String!, $project: Int!, $repo: String!, $issue: Int!) { | ||
organization(login: $org) { | ||
repository(name: $repo) { | ||
issue(number: $issue) { | ||
id | ||
number | ||
title | ||
} | ||
} | ||
projectV2(number: $project) { | ||
id | ||
title | ||
fields(first: 20) { | ||
nodes { | ||
... on ProjectV2Field { | ||
id | ||
name | ||
} | ||
... on ProjectV2SingleSelectField { | ||
id | ||
name | ||
options { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`.trim(), | ||
{ | ||
org: issueInfo.owner, | ||
project: projectNumber, | ||
repo: issueInfo.repo, | ||
issue: issueInfo.issue_number, | ||
} | ||
); | ||
|
||
if (!info.organization?.repository?.issue) { | ||
console.error("Issue not found"); | ||
process.exit(1); | ||
} | ||
|
||
if (!info.organization.projectV2) { | ||
console.error("Project not found"); | ||
process.exit(1); | ||
} | ||
|
||
type ProjectItemResponse = { | ||
readonly addProjectV2ItemById: { | ||
readonly item: { | ||
readonly id: string; | ||
}; | ||
}; | ||
}; | ||
|
||
const projectItemInfo = await github.graphql<ProjectItemResponse>( | ||
` | ||
mutation($projectId: ID!, $issueId: ID!) { | ||
addProjectV2ItemById(input: { | ||
projectId: $projectId, | ||
contentId: $issueId | ||
}) { | ||
item { | ||
id | ||
} | ||
} | ||
} | ||
`, | ||
{ | ||
projectId: info.organization.projectV2.id, | ||
issueId: info.organization.repository.issue.id, | ||
} | ||
); | ||
|
||
console.log( | ||
`Issue ${c.cyan( | ||
info.organization.repository.issue.title | ||
)} added to project ${c.yellow(info.organization.projectV2.title)}.` | ||
); | ||
|
||
const projectItemId = projectItemInfo.addProjectV2ItemById.item.id; | ||
|
||
for (const [fieldId, fieldValue] of Object.entries(fieldsSpec)) { | ||
const fieldSpec = info.organization.projectV2.fields.nodes.find( | ||
(f) => f.id === fieldId | ||
); | ||
|
||
const fieldName = fieldSpec?.name ?? `<${fieldId}>`; | ||
let valueDisplay = getValueDisplay(fieldValue, fieldSpec); | ||
|
||
await github.graphql( | ||
` | ||
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: ProjectV2FieldValue!) { | ||
updateProjectV2ItemFieldValue(input: { | ||
projectId: $projectId, | ||
itemId: $itemId, | ||
fieldId: $fieldId, | ||
value: $value | ||
}) { | ||
projectV2Item { | ||
id | ||
} | ||
} | ||
} | ||
`, | ||
{ | ||
projectId: info.organization.projectV2.id, | ||
itemId: projectItemId, | ||
fieldId, | ||
value: fieldValue, | ||
} | ||
); | ||
|
||
console.log(`Set ${c.green(fieldName)} to ${c.magenta(valueDisplay)}`); | ||
} | ||
|
||
function getValueDisplay(value: FieldValue, spec?: FieldSpec) { | ||
if ("text" in value) { | ||
return value.text; | ||
} else if ("number" in value) { | ||
return value.number.toString(); | ||
} else if ("date" in value) { | ||
return value.date; | ||
} else if ("singleSelectOptionId" in value) { | ||
return ( | ||
spec?.options?.find((o) => o.id === value.singleSelectOptionId)?.name ?? | ||
`<${value.singleSelectOptionId}>` | ||
); | ||
} else if ("iterationId" in value) { | ||
return `<${value.iterationId}>`; | ||
} else { | ||
return JSON.stringify(value); | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"name": "scripts", | ||
"version": "0.0.0", | ||
"description": "", | ||
"keywords": [], | ||
"author": "", | ||
"private": true, | ||
"devDependencies": { | ||
"@octokit/action": "^7.0.0", | ||
"@types/node": "^20.11.30", | ||
"chalk": "^5.3.0", | ||
"globby": "^14.0.1", | ||
"tsx": "^4.7.1", | ||
"typescript": "^5.4.3", | ||
"zx": "^8.0.0" | ||
} | ||
} |
Oops, something went wrong.