Skip to content

Commit

Permalink
added manuel deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Erling Jahr committed Jun 6, 2024
1 parent 07703e1 commit 9fac449
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 2 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/MD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: MD

on:
workflow_dispatch:
inputs:
cluster:
description: 'Select and environment'
required: true
default: 'warning'
type: choice
options:
- aks-beta-fint-2021-11-23
- aks-api-fint-2022-02-08
org:
description: 'Select organisation'
required: true
default: 'warning'
type: choice
options:
- fintlabs-no
- ofk-no
- bfk-no
- afk-no

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CLUSTER_NAME: ${{ inputs.cluster }}
ORG: ${{ inputs.org }}

jobs:
cd:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/github-script@v6
name: Get resource group name
id: rg
with:
script: |
const a = '${{ inputs.cluster }}'.split('-')
return `rg-${a[0]}-${a[1]}`
result-encoding: string

- uses: actions/github-script@v6
name: Get environment
id: environment
with:
script: |
const a = '${{ inputs.cluster }}'.split('-')
return `${a[1]}`
result-encoding: string
- uses: actions/github-script@v6
name: Get auth
id: auth
with:
script: |
const e = '${{ steps.environment.outputs.result }}'.toUpperCase()
return `secrets.AKS_${e}_FINT_GITHUB`
result-encoding: string

- run: |
echo "Cluster: $CLUSTER_NAME"
echo "Resource group: ${{ steps.rg.outputs.result }}"
echo "Environment: ${{ steps.environment.outputs.result }}"
echo "OrgId: $ORG"
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,enable=true,priority=100,prefix=sha-,suffix=,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Bake manifests with Kustomize
uses: azure/k8s-bake@v2
with:
renderEngine: 'kustomize'
kustomizationPath: 'kustomize/overlays/${{ steps.environment.outputs.result }}/${{ env.ORG}}'
id: bake

- uses: azure/login@v1
with:
creds: "${{ secrets[format('AKS_{0}_FINT_GITHUB', steps.environment.outputs.result)] }}"

- uses: azure/use-kubelogin@v1
with:
kubelogin-version: 'v0.0.32'

- name: Set the target cluster
uses: azure/aks-set-context@v3
with:
cluster-name: ${{ env.CLUSTER_NAME }}
resource-group: ${{ steps.rg.outputs.result }}
admin: 'true'
use-kubelogin: 'true'

- name: Deploy to ${{ env.CLUSTER_NAME }}
uses: azure/k8s-deploy@v4
with:
manifests: ${{ steps.bake.outputs.manifestsBundle }}
images: |
${{ steps.meta.outputs.tags }}
namespace: ${{ env.ORG }}
action: deploy
4 changes: 2 additions & 2 deletions src/main/java/no/fintlabs/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ResponseEntity<Map<String,Object>> getSimpleUsers(@AuthenticationPrincipa
@RequestParam(defaultValue = "${fint.kontroll.user-catalog.pagesize:20}") int size
){

log.info("Finding users with search: " + search + " with orgUnitIDs: " + orgUnits + " with UserType: " + userType);
log.info("Finding users with search: {} with orgUnitIDs: {} with UserType: {}", search, orgUnits, userType);


if (orgUnits == null){
Expand All @@ -51,7 +51,7 @@ public ResponseEntity<Map<String,Object>> getSimpleUsers(@AuthenticationPrincipa

@GetMapping({"{id}"})
public ResponseEntity<DetailedUser> getDetailedUserById(@AuthenticationPrincipal Jwt jwt, @PathVariable Long id) {
log.info("Fetching user by id: " + id);
log.info("Fetching user by id: {}", id);
DetailedUser detailedUserById = userService.getDetailedUserById(FintJwtEndUserPrincipal.from(jwt), id);
if (detailedUserById.isValid()){
return new ResponseEntity<>(detailedUserById, HttpStatus.OK);
Expand Down

0 comments on commit 9fac449

Please sign in to comment.