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 to Production #2984

Merged
merged 62 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f1707e9
gh-ssb to gh-ssbno for testing
Carl-OW Oct 9, 2024
954ac3c
google-github-actions/auth update
Carl-OW Oct 9, 2024
3c835c9
Merge pull request #2937 from statisticsnorway/MIM-2005-Nais-delete-y…
Carl-OW Oct 9, 2024
da89809
Bump google-github-actions/auth from 0.6.0 to 2.1.6 (#2933)
dependabot[bot] Oct 10, 2024
7d13f7d
Bump cookie and socket.io (#2939)
dependabot[bot] Oct 10, 2024
d58fdaf
Create backstage yaml (#2940)
johnnadeluy Oct 10, 2024
339bdac
[MIM-1883] Mim 1883 publish dataset draft (#2930)
ssb-cgn Oct 10, 2024
01f6b3b
Bump the dependencies-minor-updates group across 1 directory with 10 …
dependabot[bot] Oct 14, 2024
085581a
ssbno back to ssb
Carl-OW Oct 14, 2024
0dc228b
name change
Carl-OW Oct 15, 2024
b2042fa
Merge pull request #2945 from statisticsnorway/MIM-2005-Nais-delete-y…
Carl-OW Oct 15, 2024
ccb7aa9
update 2.1.6
Carl-OW Oct 15, 2024
d61060c
v2.2.1
Carl-OW Oct 15, 2024
ae8791c
v
Carl-OW Oct 15, 2024
642e560
Bump send and browser-sync (#2943)
dependabot[bot] Oct 15, 2024
9970feb
TTL = 0 - test
Carl-OW Oct 17, 2024
320dc64
deployment
Carl-OW Oct 17, 2024
6568a82
More optimal solution test
Carl-OW Oct 17, 2024
a51320b
Merge pull request #2948 from statisticsnorway/MIM-2005-nais-alterati…
Carl-OW Oct 17, 2024
ead168f
e
Carl-OW Oct 17, 2024
2891ee1
TTL 0
Carl-OW Oct 17, 2024
9a01226
Merge pull request #2951 from statisticsnorway/MIM-2005-nais-alterati…
Carl-OW Oct 17, 2024
2345fd2
../../nais.yaml
Carl-OW Oct 17, 2024
1295f55
workflow_dispatch
Carl-OW Oct 17, 2024
4db69b2
-e
Carl-OW Oct 17, 2024
8171491
Merge pull request #2952 from statisticsnorway/MIM-2005-nais-deploy-t…
Carl-OW Oct 17, 2024
fbb8a18
if:
Carl-OW Oct 17, 2024
0d3776b
Revert back to non workflow_dispatch
Carl-OW Oct 17, 2024
292a3a1
Merge pull request #2954 from statisticsnorway/MIM-nais-delete-file-f…
Carl-OW Oct 17, 2024
94d22b6
nais checkout to branch
Carl-OW Oct 17, 2024
d7f2bb1
Merge pull request #2955 from statisticsnorway/MIM-2005-delete_nais_a…
Carl-OW Oct 17, 2024
b53e849
sed ' '
Carl-OW Oct 17, 2024
c4001cb
" "
Carl-OW Oct 17, 2024
585a3b4
changes
Carl-OW Oct 17, 2024
a44bae6
.
Carl-OW Oct 17, 2024
272ad41
Merge pull request #2956 from statisticsnorway/MIM-2005-nais-sid-test
Carl-OW Oct 17, 2024
1a71e98
back to original nais.yaml
Carl-OW Oct 17, 2024
9a36021
'{{ image }}'
Carl-OW Oct 17, 2024
80ee230
Merge pull request #2961 from statisticsnorway/MIM-2005-proper-nais-a…
Carl-OW Oct 17, 2024
2a8fb83
sed alterations for ubuntu latest
Carl-OW Oct 17, 2024
d147686
Merge pull request #2963 from statisticsnorway/MIM-2005-proper-nais-a…
Carl-OW Oct 17, 2024
3e09a8e
sed fix
Carl-OW Oct 17, 2024
935fa95
Merge pull request #2964 from statisticsnorway/MIM-2005-proper-nais-a…
Carl-OW Oct 17, 2024
db1a9ab
2m
Carl-OW Oct 18, 2024
38d2ae9
10m
Carl-OW Oct 18, 2024
e411fbb
Merge pull request #2965 from statisticsnorway/MIM-2005-proper-nais-t…
Carl-OW Oct 18, 2024
701e052
Use same image as the orignal PR
Carl-OW Oct 18, 2024
a8b0f4f
Merge pull request #2968 from statisticsnorway/MIM-2005-proper-nais-t…
Carl-OW Oct 18, 2024
df13e82
Bump the dependencies-patch-updates group with 10 updates (#2971)
dependabot[bot] Oct 21, 2024
dd89d36
[MIM-2091] MIM-2091:Fixed bug with table view if only draft dataset (…
ssb-cgn Oct 21, 2024
8328852
using artifact registry for imagename accross jobs
Carl-OW Oct 22, 2024
6635c30
Merge pull request #2978 from statisticsnorway/MIM-2005-nais-alterati…
Carl-OW Oct 22, 2024
f21debd
Try adding TTL edit to deploy script
Glenruben Oct 22, 2024
64c9dca
Merge pull request #2979 from statisticsnorway/MIM-2005-add-condition…
Glenruben Oct 22, 2024
e3dd078
Add some Nais feature deploy documentation
Glenruben Oct 22, 2024
394c92c
Merge pull request #2980 from statisticsnorway/MIM-2005-test-undeploy…
Glenruben Oct 22, 2024
ed7458f
remove branch name test, need to trigger PR close on develop
Glenruben Oct 23, 2024
c9ac1ed
Merge pull request #2982 from statisticsnorway/MIM-2005-test-undeploy…
Glenruben Oct 23, 2024
8ac7970
add change, to test deployment flow
Glenruben Oct 23, 2024
ebe49b4
Merge pull request #2983 from statisticsnorway/MIM-2005-test-undeploy…
Glenruben Oct 23, 2024
4e2d787
[MIM-2091] MIM-2091:Revert view text if empty table (#2981)
ssb-cgn Oct 23, 2024
d7709c1
Bump version number v2.16.0 (#2985)
github-actions[bot] Oct 24, 2024
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
2 changes: 1 addition & 1 deletion .github/auto_assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ assignees:
- johnnadeluy
# - annesiri
- Carl-OW
- michaelpande
# - michaelpande

# A number of assignees to add to the pull request
# Set to 0 to add all of the assignees.
Expand Down
76 changes: 53 additions & 23 deletions .github/workflows/delete_nais.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
name: NAIS Deploy
name: NAIS Delete

on: workflow_dispatch

on:
pull_request:
types: [closed]

jobs:
delete:
name: 'Delete app from cluster'
permissions:
contents: "read"
id-token: "write"
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))
if: (startsWith(github.head_ref, 'MIM-') || startsWith(github.head_ref, 'mim-') && contains(github.event.pull_request.labels.*.name, 'nais') && contains(fromJSON('["annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW", "michaelpande"]'), github.actor))
env:
REGISTRY: europe-north1-docker.pkg.dev/nais-management-b3a7/ssbno/ssbno-mimir
IMAGE: mimir
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"
# Checkout the PR branch (e.g., MIM-2005-nais-deploy-test-6)
- name: Checkout the PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Check out the branch associated with the PR

# Get the JIRA issue number (same logic from deploy)
- name: 'Get JIRA issue number'
id: jira_issue_number
run: |
BRANCH="${{ github.head_ref }}"
Expand All @@ -23,17 +30,40 @@ jobs:
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]"
# Authenticate to Google Cloud
- 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"
workload_identity_provider: 'projects/906675412832/locations/global/workloadIdentityPools/ssb-identity-pool/providers/github-oidc-provider'
service_account: '[email protected]'
token_format: 'access_token'

# Verify nais.yaml exists
- name: Verify nais.yaml exists
run: |
if [ ! -f "nais.yaml" ]; then
echo "nais.yaml not found!"
exit 1
else
echo "nais.yaml found."
fi

# Modify nais.yaml to set TTL to "10m" (must be string value)
- name: Set TTL to "10m" in nais.yaml
run: |
sed -i 's/ttl: .*/ttl: "10m"/' nais.yaml

# Use the stored image tag from the deploy job
- name: Retrieve the original image tag
run: |
echo "Using stored image tag: ${{ env.IMAGE_TAG }}"

# Redeploy the application with the modified TTL and correct image and branch variables
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
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
55 changes: 27 additions & 28 deletions .github/workflows/deploy_nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ name: NAIS Deploy
on:
pull_request:
types: [labeled]
# types: [opened]
# paths:
# - 'src/**'
# - 'build.gradle'
# - 'package.json'


env:
REGISTRY: europe-north1-docker.pkg.dev/nais-management-b3a7/ssbno/ssbno-mimir
IMAGE: mimir
Expand All @@ -19,7 +13,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('["annesiri", "ssb-cgn", "Glenruben", "johnnadeluy", "Carl-OW", "michaelpande"]'), github.actor))
if: (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 All @@ -31,14 +25,13 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: mimir-nais-${{ github.run_number }}
path: "./build/libs/*.jar"

path: './build/libs/*.jar'

build_image_and_push:
needs: build_xp
permissions:
contents: "read"
id-token: "write"
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Calculate sha
Expand All @@ -48,24 +41,29 @@ jobs:
- name: Checkout mimir
uses: actions/checkout@v4

- name: Edit TTL for Undeploy
if: github.event.pull_request.merged == true
run: |
sed -i 's/ttl: .*/ttl: "10m"/' nais.yaml

- name: Give GitHub Actions acces to docker repo
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DOCKER_REPO_READ_KEY }}
- name: Checkout docker
uses: actions/checkout@v4
with:
ref: "master"
path: "ssbno-xp-docker"
repository: "statisticsnorway/ssbno-xp-docker"
ref: 'master'
path: 'ssbno-xp-docker'
repository: 'statisticsnorway/ssbno-xp-docker'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: mimir-nais-${{ github.run_number }}
path: "./ssbno-xp-docker"
path: './ssbno-xp-docker'

# 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"
- name: 'Get JIRA issue number'
id: jira_issue_number
run: |
BRANCH="${{ github.head_ref }}"
Expand All @@ -74,22 +72,22 @@ jobs:
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].5"
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/[email protected].6'
with:
workload_identity_provider: "projects/906675412832/locations/global/workloadIdentityPools/ssb-identity-pool/providers/github-oidc-provider"
service_account: "[email protected]"
token_format: "access_token"
workload_identity_provider: 'projects/906675412832/locations/global/workloadIdentityPools/ssb-identity-pool/providers/github-oidc-provider'
service_account: '[email protected]'
token_format: 'access_token'
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
- name: Docker meta
id: metadata
uses: docker/metadata-action@v5
Expand All @@ -109,31 +107,32 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./ssbno-xp-docker
file: "./ssbno-xp-docker/Dockerfile"
file: './ssbno-xp-docker/Dockerfile'
push: true
tags: ${{ steps.metadata.outputs.tags }}
# tags: ${{ github.ref_name }}-${{ github.sha }}
labels: ${{ steps.metadata.outputs.labels }}


deploy:
name: Deploy to NAIS
needs: build_image_and_push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Get JIRA 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";
- name: 'Store image tag'
run: echo "IMAGE_TAG=${{ env.TAG }}" >> $GITHUB_ENV
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
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
DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443
21 changes: 21 additions & 0 deletions backstage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: mimir
description: |
Content Management Solution for ssb.no
links:
- title: Enonic Admin
url: https://ssb-xp7p-admin.enonic.cloud/xp/admin/tool
tags:
- typescript
- javascript
- react
- enonic-xp
annotations:
github.com/project-slug: statisticsnorway/mimir
spec:
type: website
system: SSBNO
owner: ssbno-developers
lifecycle: production
6 changes: 5 additions & 1 deletion docs/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ In order to bypass Varnish, we will sometimes want to run the tests directly tow
Further improvements and more test coverage might be a useful addition.
- Begin with the [quick start](https://gatling.io/docs/gatling/tutorials/quickstart/) to Gatling
- Refer do the [Cheat sheet](https://gatling.io/docs/gatling/reference/current/cheat-sheet/) and further documentation for reference.
- The Gatling zip package contains useful examples, don't forget to check them out!
- The Gatling zip package contains useful examples, don't forget to check them out!

## Deploying feature branches to Nais
We use a gihub pull request label to ensure we control which branches are deployed to Nais.
Add the branch `nais` to deploy your branch with a minimal set of test content! Maybe it even takes down the branch environment when you close the PR!
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.15.0
version = 2.16.0

# XP App values
appDisplayName = Mimir application
Expand Down
12 changes: 6 additions & 6 deletions nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ metadata:
name: mimir-branch-{{branch}}
namespace: ssbno
annotations:
nais.io/read-only-file-system: "false"
nais.io/run-as-user: "1337"
nais.io/read-only-file-system: 'false'
nais.io/run-as-user: '1337'
labels:
team: ssbno
spec:
image: {{ image }}
# image: europe-north1-docker.pkg.dev/nais-management-b3a7/ssbno/ssbno-mimir/mimir:...
image: '{{ image }}'
# image: europe-north1-docker.pkg.dev/nais-management-b3a7/ssbno/ssbno-mimir/mimir:...
# ^--- interpolated from the ${{ env.docker_image }} variable in the action

replicas:
Expand Down Expand Up @@ -39,9 +39,9 @@ spec:
prometheus:
enabled: false

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

ingresses:
- https://ssbno-{{branch}}.external.test.ssb.cloud.nais.io # must match vhost
- https://ssbno-{{branch}}.external.test.ssb.cloud.nais.io # must match vhost
Loading
Loading