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

Deploy app to production #19

Merged
merged 18 commits into from
May 2, 2024
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
tmp
.vscode
.idea
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# FORMS
DATAJEGER_EMAIL_ADDRESS=datajegeren.staging@norge.no
FDK_MAIL_SERVICE_ENDPOINT=mail-sender-service.staging.fellesdatakatalog.digdir.no/api/sendmail
FDK_MAIL_SERVICE_API_KEY=
FDK_BASE_URI=https://staging.fellesdatakatalog.digdir.no
FDK_COMMUNITY_BASE_URI=https://community.staging.fellesdatakatalog.digdir.no
FDK_REGISTRATION_BASE_URI=https://registrering.staging.fellesdatakatalog.digdir.no
#
121 changes: 121 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"root": true,
"ignorePatterns": ["node_modules", "**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": [
"plugin:import/recommended",
"plugin:@nx/typescript",
"plugin:@typescript-eslint/eslint-plugin/recommended",
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"prettier"
],
"rules": {
"import/no-unresolved": "off",
"react/react-in-jsx-scope": "off",
"no-console": "off",
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(error)$/]",
"message": "Unexpected property on console object was called"
}
],
"no-duplicate-imports": "error",
"arrow-body-style": ["warn", "as-needed"],
"require-atomic-updates": "error",
"no-use-before-define": "error",
"no-unreachable-loop": "error",
"no-unmodified-loop-condition": "error",
"no-promise-executor-return": "error",
"no-await-in-loop": "error",
"camelcase": "error",
"complexity": ["warn", 10],
"consistent-return": "warn",
"curly": "warn",
"default-case": "error",
"default-case-last": "error",
"default-param-last": "error",
"eqeqeq": ["error", "smart"],
"func-style": ["error", "expression", { "allowArrowFunctions": true }],
"max-depth": ["warn", 4],
"max-lines": ["warn", 300],
"no-alert": "warn",
"no-empty-function": "warn",
"no-eq-null": "error",
"no-implicit-coercion": "warn",
"no-magic-numbers": ["warn", { "ignoreArrayIndexes": true }],
"no-param-reassign": "error",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"prefer-const": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": [
"plugin:import/recommended",
"plugin:@nx/javascript",
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"prettier"
],
"rules": {
"react/react-in-jsx-scope": "off",
"no-console": "warn",
"no-duplicate-imports": "error",
"arrow-body-style": ["warn", "as-needed"],
"require-atomic-updates": "error",
"no-use-before-define": "error",
"no-unreachable-loop": "error",
"no-unmodified-loop-condition": "error",
"no-promise-executor-return": "error",
"no-await-in-loop": "error",
"camelcase": "error",
"complexity": ["warn", 10],
"consistent-return": "warn",
"curly": "warn",
"default-case": "error",
"default-case-last": "error",
"default-param-last": "error",
"eqeqeq": ["error", "smart"],
"func-style": ["error", "expression", { "allowArrowFunctions": true }],
"max-depth": ["warn", 4],
"max-lines": ["warn", 300],
"no-alert": "warn",
"no-empty-function": "warn",
"no-eq-null": "error",
"no-implicit-coercion": "warn",
"no-magic-numbers": ["warn", { "ignoreArrayIndexes": true }],
"no-param-reassign": "error",
"no-shadow": "error",
"prefer-const": "error"
}
}
]
}
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Bug rapport
about: Lag en bug rapport
title: '[Bug]: kort beskrivelse av problemet'
labels: 'bug'
---

## 🐛 Bug rapport

### Nåværende oppførsel

### Forventet oppførsel

### Hvordan reprodusere?

### Forslag/Løsning [Valgfritt]
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Feature forespørsel
about: Forespør en ny feature
title: '[Feat]: kort beskrivelse av feature'
labels: 'enhancement'
---

## 🚀 Feature forespørsel

### Feature beskrivelse

### Hvorfor trenger vi det?

### Forslag/løsning [Valgfritt]

### Definisjon av ferdig
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/ux_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: UX issue
about: Lag et UX issue
title: '[UX]: kort beskrivelse av problemet'
labels: 'ux'
---

## 🪄 UX rapport

### Nåværende oppførsel

### Dette er et problem fordi:

### Forventet oppførsel/ønsket oppførsel

### Skjermbilder
22 changes: 22 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Code scanning (CodeQL)

on:
pull_request:
types: [ready_for_review, opened, reopened, synchronize]
branches:
- main
push:
branches:
- main
schedule:
- cron: '0 2 * * *'

jobs:
codeql:
name: Run codeql scan
if: github.event.pull_request.draft == false
uses: Informasjonsforvaltning/workflows/.github/workflows/codeql.yaml@main
with:
language: javascript
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118 changes: 118 additions & 0 deletions .github/workflows/deploy-prod&demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Deploy to production and demo

on:
push:
branches:
- main
workflow_dispatch:

jobs:
test:
name: Test and build
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
changed: ${{ steps.set-matrix.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0

- name: Set SHAs
uses: nrwl/nx-set-shas@v4

- name: Enable corepack
run: corepack enable

- name: Use Node.js 20.9.0
uses: actions/setup-node@v4
with:
node-version: 20.9.0
cache: 'yarn'

- name: Yarn install
run: |
corepack enable
yarn set version stable
yarn install --frozen-lockfile

- name: Caching Nx
uses: actions/cache@v4
with:
path: node_modules/.cache
key: cache-nx-${{ hashFiles('yarn.lock') }}

- id: set-matrix
run: |
echo "matrix={\"appname\":$(yarn --silent run matrix)}" >> $GITHUB_OUTPUT
echo "changed=$(yarn --silent run matrix)" >> $GITHUB_OUTPUT

- run: yarn run affected:lint --parallel=2
- run: yarn run affected:test --parallel=2 --configuration=ci
- run: yarn run affected:e2e --parallel=2 --configuration=ci
- run: yarn run affected:build --parallel=2 --configuration=ci

- name: Caching Dist Folder
uses: actions/cache@v4
with:
path: ./dist
key: cache-dist-${{ github.sha }}

build:
name: Build affected apps when pull request is created
needs: [test]
if: ${{ needs.test.outputs.changed != '[]' }}
strategy:
matrix: ${{fromJSON(needs.test.outputs.matrix)}}
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: ${{ matrix.appname }}-frontend
environment: prod
build_env: true
build_env_name: BINARY
build_env_value: ${{ matrix.appname }}-frontend
cache_path: ./dist
cache_key: cache-dist-${{ github.sha }}
dockerfile: apps/${{ matrix.appname }}/Dockerfile
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }}

deploy-prod:
name: Deploy affected apps to production environment with reusable workflow
needs: [test, build]
strategy:
matrix: ${{fromJSON(needs.test.outputs.matrix)}}
fail-fast: false
if: ${{ needs.test.outputs.changed != '[]' }}
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: ${{ matrix.appname }}-frontend
environment: prod
monorepo_app: true
cluster: digdir-fdk-prod
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_PROD_AUTODEPLOY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

deploy-demo:
name: Deploy affected apps to demo environment with reusable workflow
needs: [test, deploy-prod]
strategy:
matrix: ${{fromJSON(needs.test.outputs.matrix)}}
fail-fast: false
if: ${{ needs.test.outputs.changed != '[]' }}
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: ${{ matrix.appname }}-frontend
environment: demo
monorepo_app: true
cluster: digdir-fdk-dev
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_DEV_AUTODEPLOY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading