Skip to content

Commit

Permalink
Merge pull request #2935 from statisticsnorway/develop
Browse files Browse the repository at this point in the history
Deploy to Production

🚀
  • Loading branch information
Glenruben authored Oct 8, 2024
2 parents fccc8ac + 46a5fb8 commit fcfdf74
Show file tree
Hide file tree
Showing 45 changed files with 414 additions and 217 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/delete_nais.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: NAIS Deploy

on:
pull_request:
types: [closed]

jobs:
delete:
name: 'Delete app from cluster'
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
if: (startsWith(github.head_ref, 'MIM-') || startsWith(github.head_ref, 'mim-') && contains(github.event.issue.labels.*.name, 'nais') && contains(fromJSON('["annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW", "michaelpande"]'), github.actor))
steps:
# turn 'MIM-9876_new_feature' into 'mim-9876' so it can be used in URL, it can be found in env.ISSUE_NUMBER
- name: "Get JIRA issue number"
id: jira_issue_number
run: |
BRANCH="${{ github.head_ref }}"
ISSUE_NUMBER=${BRANCH:0:8}
ISSUE_NUMBER=$(echo $ISSUE_NUMBER | tr '[:upper:]' '[:lower:]')
echo "ISSUE_NUMBER=${ISSUE_NUMBER}" >> $GITHUB_ENV;
echo "Issue number: $ISSUE_NUMBER";
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/[email protected]"
with:
workload_identity_provider: "projects/906675412832/locations/global/workloadIdentityPools/ssb-identity-pool/providers/github-oidc-provider"
service_account: "[email protected]"
token_format: "access_token"
- id: "get-credentials"
uses: 'google-github-actions/get-gke-credentials@v2'
with:
cluster_name: 'nais-test'
location: 'europe-north1'
- id: "delete"
run: "kubectl delete pod -n ssbno --selector=app=mimir-branch-${{ env.ISSUE_NUMBER }} --ignore-not-found=true"
4 changes: 2 additions & 2 deletions .github/workflows/deploy_nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
build_xp:
name: 'Build XP jar'
runs-on: 'ubuntu-latest'
if: (startsWith(github.head_ref, 'MIM-') || startsWith(github.head_ref, 'mim-') && github.event.label.name == 'nais' && contains(fromJSON('["omsaggau", "annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW", "michaelpande"]'), github.actor))
if: (startsWith(github.head_ref, 'MIM-') || startsWith(github.head_ref, 'mim-') && github.event.label.name == 'nais' && contains(fromJSON('["annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW", "michaelpande"]'), github.actor))
steps:
- id: build_app
uses: enonic/release-tools/build-and-publish@master
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: staging
CLUSTER: test
RESOURCE: nais.yaml
VAR: image=${{ env.REGISTRY }}/${{env.IMAGE}}:${{ env.TAG }},branch=${{ env.ISSUE_NUMBER }}
DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443
2 changes: 1 addition & 1 deletion .github/workflows/update_mimir_version_number.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
update_pr:
runs-on: ubuntu-latest
if: >-
contains(fromJSON('["patch-release", "major-release", "minor-release"]'), github.event.label.name) && contains(fromJSON('["omsaggau", "annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW"]'), github.actor)
contains(fromJSON('["patch-release", "major-release", "minor-release"]'), github.event.label.name) && contains(fromJSON('["annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW"]'), github.actor)
steps:
- name: Determine Version Bump Type
id: determine_bump_type
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gradle Project settings
projectName = mimir
version = 2.14.0
version = 2.15.0

# XP App values
appDisplayName = Mimir application
Expand Down
4 changes: 2 additions & 2 deletions nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:

env:
- name: VHOST_HOST
value: ssbno-{{branch}}.external.staging.ssb.cloud.nais.io
value: ssbno-{{branch}}.external.test.ssb.cloud.nais.io

ingresses:
- https://ssbno-{{branch}}.external.staging.ssb.cloud.nais.io # must match vhost
- https://ssbno-{{branch}}.external.test.ssb.cloud.nais.io # must match vhost
2 changes: 1 addition & 1 deletion src/main/resources/admin/tools/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</nav>
<div class="misc">
<div class="logo-container">
<img data-th-src="${logoUrl}" class="logo" alt="" />
<img data-th-src="${logoUrl}" class="logo" alt="" loading='lazy'/>
<span data-th-if="${environmentText}" data-th-utext="${environmentText}" class="environment-logo-overlay" />
</div>
<h1>Dashboard</h1>
Expand Down
50 changes: 35 additions & 15 deletions src/main/resources/lib/ssb/cron/pushRss.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { HttpRequestParams, HttpResponse, request } from '/lib/http-client'
import { getRssItemsStatkal } from '/lib/ssb/rss/statkal'
import { encryptRssNews, encryptRssStatkal } from '/lib/cipher/cipherRss'

export function pushRssNews(): string {
import { getRssItemsStatkal } from '../../../lib/ssb/rss/statkal'
import { encryptRssNews, encryptRssStatkal } from '../../../lib/cipher/cipherRss'
import { Events } from '../../../lib/ssb/repo/query'

export function pushRssNews(): RssResult {
const newsServiceUrl: string = app.config?.['ssb.baseUrl']
? app.config['ssb.baseUrl'] + '/_/service/mimir/news'
: 'https://www.utv.ssb.no/_/service/mimir/news'
Expand All @@ -11,17 +13,17 @@ export function pushRssNews(): string {
const encryptedBody: string = encryptRssNews(rssNews.body)
return postRssNews(encryptedBody)
} else {
return rssNews.message
return { message: rssNews.message }
}
}

export function pushRssStatkal(): string {
export function pushRssStatkal(): RssResult {
const rssStatkal: string | null = getRssItemsStatkal()
if (rssStatkal !== null) {
const encryptedBody: string = encryptRssStatkal(rssStatkal)
return postRssStatkal(encryptedBody)
} else {
return 'Ingen publiseringer å pushe til rss/statkal'
return { message: 'Ingen publiseringer å pushe til rss/statkal' }
}
}

Expand All @@ -47,15 +49,16 @@ function getRssNews(url: string): RssItems {
}
} else {
status.message = 'Henting av nyheter XP feilet - ' + rssNewsResponse.status
status.status = Events.REQUEST_GOT_ERROR_RESPONSE
}
} catch (e) {
status.message = 'Henting av nyheter XP feilet - ' + e
status.status = Events.REQUEST_GOT_ERROR_RESPONSE
}

return status
}

function postRssNews(encryptedRss: string): string {
function postRssNews(encryptedRss: string): RssResult {
const rssNewsBaseUrl: string =
app.config && app.config['ssb.baseUrl']
? app.config['ssb.baseUrl'] + '/rss/populate/news'
Expand All @@ -72,16 +75,24 @@ function postRssNews(encryptedRss: string): string {
try {
const pushRssNewsResponse: HttpResponse = request(requestParams)
if (pushRssNewsResponse.status === 200) {
return 'Push av RSS nyheter OK'
return {
message: 'Push av RSS nyheter OK',
}
} else {
return 'Push av RSS nyheter feilet - ' + pushRssNewsResponse.status
return {
message: 'Push av RSS nyheter feilet - ' + pushRssNewsResponse.status,
status: Events.REQUEST_GOT_ERROR_RESPONSE,
}
}
} catch (e) {
return 'Push av nyheter feilet - ' + e
return {
message: 'Push av nyheter feilet - ' + e,
status: Events.REQUEST_GOT_ERROR_RESPONSE,
}
}
}

function postRssStatkal(encryptedRss: string): string {
function postRssStatkal(encryptedRss: string): RssResult {
const rssStatkalBaseUrl: string =
app.config && app.config['ssb.baseUrl']
? app.config['ssb.baseUrl'] + '/rss/populate/statkal'
Expand All @@ -98,16 +109,25 @@ function postRssStatkal(encryptedRss: string): string {
try {
const pushRssStatkalResponse: HttpResponse = request(requestParams)
if (pushRssStatkalResponse.status === 200) {
return 'Push av RSS statkal OK'
return { message: 'Push av RSS statkal OK' }
} else {
return `Push av RSS statkal til ${rssStatkalBaseUrl} feilet - ${pushRssStatkalResponse.status} `
return {
message: `Push av RSS statkal til ${rssStatkalBaseUrl} feilet - ${pushRssStatkalResponse.status}`,
status: Events.REQUEST_GOT_ERROR_RESPONSE,
}
}
} catch (e) {
return 'Push av RSS statkal feilet - ' + e
return { message: 'Push av RSS statkal feilet - ' + e, status: Events.REQUEST_GOT_ERROR_RESPONSE }
}
}

interface RssItems {
body: string | null
message: RssResult['message']
status?: RssResult['status']
}

export interface RssResult {
message: string
status?: string
}
2 changes: 2 additions & 0 deletions src/main/resources/lib/ssb/cron/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ export interface RSSFilterLogData {
otherDataType: Array<string>
inRSSOrNoKey: Array<string>
savedQueryStatistics: Array<string>
start?: Array<string>
skipped: Array<string>
end: Array<string>
statistics?: Array<string>
}

export interface DataSourceInfo {
Expand Down
Loading

0 comments on commit fcfdf74

Please sign in to comment.