Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true

# C# files
[*.cs]

#### Core EditorConfig Options ####

# Indentation and spacing
indent_size = 4
indent_style = space
tab_width = 4

# New line preferences
end_of_line = lf
insert_final_newline = true

# Analyzer severities
# IDE0005: Using directive is unnecessary
dotnet_diagnostic.IDE0005.severity = warning
# CA1873: Potentially expensive logging argument evaluation
dotnet_diagnostic.CA1873.severity = none
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build transitory-documents-api
description: Builds the transitory-documents-api codebase

inputs:
working_directory:
description: The working directory where the code will be built.
required: true
dotnet_version:
description: The .NET version that will be used.
required: true

runs:
using: composite

steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: ${{ inputs.dotnet_version }}

- run: dotnet format --verify-no-changes --severity info
shell: bash
working-directory: ${{ inputs.working_directory }}/transitory-documents-api
continue-on-error: false

- run: dotnet restore
shell: bash
working-directory: ${{ inputs.working_directory }}

- run: dotnet build --configuration Release --no-restore
shell: bash
working-directory: ${{ inputs.working_directory }}/transitory-documents-api

- run: dotnet test --no-restore --verbosity normal
shell: bash
working-directory: ${{ inputs.working_directory }}/tests
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ on:
paths:
- 'api/**'
- 'db/**'
- 'models/**'
- 'core/**'
- 'cso-client/**'
- 'dars-client/**'
- 'jc-interface-client/**'
- 'pcss-client/**'
- 'transitory-documents-client/**'
- 'tests/**'

workflow_dispatch:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/build-and-test-transitory-documents-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and Test transitory-documents-api

permissions:
contents: read

on:
pull_request:
branches:
- master
paths:
- 'transitory-documents-api/**'
- 'transitory-documents-client/**'
- 'models/**'
- 'core/**'

workflow_dispatch:

env:
WORKING_DIRECTORY: .

jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
dotnet-major-version: [10]
dotnet-minor-version: [0]

steps:
- name: Checkout repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5

- name: Building transitory documents codebase
uses: ./.github/workflows/actions/build-transitory-documents-api
with:
working_directory: ${{ env.WORKING_DIRECTORY }}
dotnet_version: ${{ matrix.dotnet-major-version }}.${{ matrix.dotnet-minor-version }}
Comment thread Fixed
123 changes: 123 additions & 0 deletions .github/workflows/publish-transitory-documents-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Deploy transitory-documents-api

on:
push:
branches:
- master
paths:
- 'transitory-documents-api/**'

workflow_dispatch:
inputs:
gitops-branch:
description: GitOps repository branch to update
required: false
default: main
gitops-environment:
description: GitOps environment (dev, test, prod)
required: false
default: dev

permissions:
contents: read
packages: write

env:
WORKING_DIRECTORY: .
IMAGE_NAME: jasper-transitory-documents-api
GITHUB_IMAGE_REPO: ghcr.io/${{ github.repository_owner }}/jasper
GITOPS_REPOSITORY: bcgov-c/tenant-gitops-e4161f
GITOPS_BRANCH: ${{ github.event.inputs.gitops-branch || 'main' }}
GITOPS_ENVIRONMENT: ${{ github.event.inputs.gitops-environment || 'dev' }}
GITOPS_FILE_PATH: deploy/transitory-documents-api/${{ github.event.inputs.gitops-environment || 'dev' }}_values.yaml

jobs:
build:
name: Build, Create and Push Image
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.short_sha.outputs.SHORT_SHA }}

strategy:
matrix:
dotnet-major-version: [10]
dotnet-minor-version: [0]

steps:
- name: Checkout repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5

- name: Build API codebase
uses: ./.github/workflows/actions/build-transitory-documents-api
with:
working_directory: ${{ env.WORKING_DIRECTORY }}
dotnet_version: ${{ matrix.dotnet-major-version }}.${{ matrix.dotnet-minor-version }}

- name: Log in to the GHCR
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get short SHA
id: short_sha
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Setup Image Metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: |
${{ env.GITHUB_IMAGE_REPO }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.short_sha.outputs.SHORT_SHA }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3

- name: Build and Push Image to ghcr.io
id: build_image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
push: true
context: .
file: ./docker/transitory-documents-api/Dockerfile.release
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
dotnet_version=${{ matrix.dotnet-major-version }}.${{ matrix.dotnet-minor-version }}

- name: Checkout tenant gitops repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
repository: ${{ env.GITOPS_REPOSITORY }}
ssh-key: ${{ secrets.TENANT_GITOPS_E4161F_DEPLOY_KEY }}
ref: ${{ env.GITOPS_BRANCH }}
path: tenant-gitops-e4161f

- name: Update transitory-documents-api dev image reference
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the image name and tag directly in the gitops repo using a file and json key path to target the repository and image tag.

uses: fjogeleit/yaml-update-action@451fb54614e46f952fc18ffd99e8c93b7b13f85e # v0.15.0
with:
workDir: tenant-gitops-e4161f
valueFile: ${{ env.GITOPS_FILE_PATH }}
changes: |
{
"$['transitory-documents-api'].image.repository": "${{ env.GITHUB_IMAGE_REPO }}/${{ env.IMAGE_NAME }}",
"$['transitory-documents-api'].image.tag": "${{ steps.short_sha.outputs.SHORT_SHA }}"
}
commitChange: false

- name: Load SSH deploy key
uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
with:
ssh-private-key: ${{ secrets.TENANT_GITOPS_E4161F_DEPLOY_KEY }}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses a deploy key for authorization.


- name: Commit and push gitops update
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
with:
cwd: tenant-gitops-e4161f
add: ${{ env.GITOPS_FILE_PATH }}
message: Update transitory-documents-api ${{ env.GITOPS_ENVIRONMENT }} image to ${{ steps.short_sha.outputs.SHORT_SHA }}
push: true
20 changes: 0 additions & 20 deletions .vscode/launch.json

This file was deleted.

29 changes: 29 additions & 0 deletions SCV.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dars-client", "dars-client\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cso-client", "cso-client\cso-client.csproj", "{3FE50416-F9ED-591F-1B5F-DBFD49311713}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "transitory-documents-api", "transitory-documents-api\transitory-documents-api.csproj", "{69C5DC46-ACCE-404C-B392-4AA0921E2543}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "transitory-documents-client", "transitory-documents-client\transitory-documents-client.csproj", "{2A5C851A-91D9-412F-8D70-A419FE8FD990}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "core", "core\core.csproj", "{EA5798DF-7387-488B-A79F-5008031A2F22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "models", "models\models.csproj", "{A4E730B4-88A7-4F22-B4F4-D60820C4A686}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4C3B75C2-DF8E-4603-A97B-7C7D6D3B0DD8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -50,6 +63,22 @@ Global
{3FE50416-F9ED-591F-1B5F-DBFD49311713}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FE50416-F9ED-591F-1B5F-DBFD49311713}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FE50416-F9ED-591F-1B5F-DBFD49311713}.Release|Any CPU.Build.0 = Release|Any CPU
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Release|Any CPU.Build.0 = Release|Any CPU
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Release|Any CPU.Build.0 = Release|Any CPU
{EA5798DF-7387-488B-A79F-5008031A2F22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA5798DF-7387-488B-A79F-5008031A2F22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA5798DF-7387-488B-A79F-5008031A2F22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA5798DF-7387-488B-A79F-5008031A2F22}.Release|Any CPU.Build.0 = Release|Any CPU
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion api/Controllers/AccessControlManagementControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using FluentValidation;
using Microsoft.AspNetCore.Mvc;
using MongoDB.Bson;
using Scv.Api.Models;
using Scv.Api.Services;
using Scv.Models;

namespace Scv.Api.Controllers;

Expand Down
7 changes: 3 additions & 4 deletions api/Controllers/ApplicationController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System.Reflection;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Scv.Api.Helpers;
using Scv.Api.Infrastructure.Authorization;
using Scv.Api.Services;
using System.Threading.Tasks;
using Scv.Core.Helpers.Extensions;

namespace Scv.Api.Controllers;

Expand Down Expand Up @@ -40,4 +39,4 @@ public async Task<IActionResult> GetApplicationInfo()
Configuration = dbConfig,
});
}
}
}
10 changes: 5 additions & 5 deletions api/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Scv.Api.Helpers;
using Scv.Api.Helpers.Extensions;
using Scv.Api.Infrastructure.Authorization;
using Scv.Api.Infrastructure.Encryption;
using Scv.Api.Models.auth;
using Scv.Core.Helpers;
using Scv.Core.Helpers.Extensions;
using Scv.Db.Models;
using Scv.Db.Models.Auth;
using Scv.Models.auth;

namespace Scv.Api.Controllers
{
Expand Down Expand Up @@ -46,8 +46,8 @@ public async Task<IActionResult> Logout()

var logoutUrl = $"{Configuration.GetNonEmptyValue("Keycloak:Authority")}/protocol/openid-connect/logout";

var forwardedHost = HttpContext.Request.Headers.ContainsKey("X-Forwarded-Host")
? HttpContext.Request.Headers["X-Forwarded-Host"].ToString()
var forwardedHost = HttpContext.Request.Headers.TryGetValue("X-Forwarded-Host", out Microsoft.Extensions.Primitives.StringValues value)
? value.ToString()
: Request.Host.ToString();
var forwardedPort = HttpContext.Request.Headers["X-Forwarded-Port"];

Expand Down
6 changes: 2 additions & 4 deletions api/Controllers/BindersController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Scv.Api.Documents;
using Scv.Api.Infrastructure.Authorization;
using Scv.Api.Models;
using Scv.Api.Services;
using Scv.Models;

namespace Scv.Api.Controllers;

Expand Down
4 changes: 2 additions & 2 deletions api/Controllers/CasesController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Scv.Api.Helpers.Extensions;
using Scv.Api.Infrastructure.Authorization;
using Scv.Api.Services;
using Scv.Core.Helpers.Extensions;

namespace Scv.Api.Controllers;

Expand All @@ -21,4 +21,4 @@ public async Task<ActionResult> GetAssignedCases(int? judgeId = null)

return Ok(judgeCases);
}
}
}
Loading
Loading