Skip to main content

Register Deployments

A deployment is:

  • Updating a frontend app on gjensidige.no by publishing a new js-bundle to CDN
  • Updating a backend API on Kubernetes with ArgoCD
  • Updating infrastructure in Azure with Terraform
  • Deploying a new artifact with Octopus Deploy
  • ...

A deployment is not:

  • Releasing a new version of a library or module to GitHub Packages or Nexus
  • Pushing a new container image to a container registry
  • ...

GitHub Actions

The Gjensidige register-deploy-action can be used to register deploys done with GitHub Actions.

Simple example

.github/workflows/deploy.yml
name: "Deploy"

on:
push:
branches:
- "main"

jobs:
checks:
name: "Deploy"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
uses: actions/checkout@v2

- name: "Deploy"
run: echo "Much Deploy, Such Success"

- name: "Register Deploy"
uses: gjensidige/register-deploy-action@main
with:
env: "test" # select "dev", "test" or "prod"
type: "infrastructure" # select "frontend", "backend", "infrastructure" or "datapipeline"
appName: "your-app-name" # optional: defaults to repo name
team: "your-team-name"
apiUrl: ${{ secrets.DEV_KPIS_API_URL }}
apiToken: ${{ secrets.DEV_KPIS_API_TOKEN }}

Example with multiple environments

.github/workflows/deploy.yml
name: "Deploy"

on:
push:
branches:
- "main"

env:
REGISTER_DEPLOY_APP_NAME: "your-app-name" # optional: defaults to repo name
REGISTER_DEPLOY_TEAM: "your-team-name"
REGISTER_DEPLOY_TYPE: "frontend" # select "frontend", "backend", "infrastructure" or "datapipeline"
REGISTER_DEPLOY_API_URL: ${{ secrets.DEV_KPIS_API_URL }}
REGISTER_DEPLOY_API_TOKEN: ${{ secrets.DEV_KPIS_API_TOKEN }}

jobs:
checks:
name: "Deploy"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
uses: actions/checkout@v2

- name: "Deploy Test"
run: echo "Much Deploy to Test, Such Success"

- name: "Register Deploy Test"
uses: gjensidige/register-deploy-action@main
with:
env: "test" # select "dev", "test" or "prod"

- name: "Deploy Prod"
run: echo "Much Deploy to Prod, Such Success"

- name: "Register Deploy Prod"
uses: gjensidige/register-deploy-action@main
with:
env: "prod" # select "dev", "test" or "prod"

Argo CD

Deploys with Argo CD are done automatically if you add the following labels:

application.yml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "your-application.{{ .Values.clusterName }}"
namespace: "argocd"
labels:
team: "your-team"
argocd.gjensidige.io/update-github-status: "true"
argocd.gjensidige.io/register-deploy: "true"
argocd.gjensidige.io/env: "test" # select "dev", "test" or "prod"
argocd.gjensidige.io/type: "backend" # select "frontend", "backend", "infrastructure" or "datapipeline"
spec:
project: "your-team"
source:
repoURL: "https://github.com/gjensidige/your-repo.git"
targetRevision: "HEAD"
path: "manifests"
destination:
name: {{ .Values.destination }}
namespace: "your-namespace"

When application code and Kubernetes manifests are in two separate repos

To be able to register deployments and calculate lead time for changes done in the application code repo, you need to add some structured information in commit messages to the Kubernetes manifests repo. The following string has to be included (format have to be followed strictly):

repo=<name of app repo>,commitSha=<commit sha from app repo>,type=<frontend/backend/datapipeline>

An example can be seen in the release workflow for the repo platform-kubernetes-manifests.

You might want to change the label argocd.gjensidige.io/type in your Argo CD Application resource to infrastructure to register changes in the Kubernetes manifests repo as type of "infrastructure".

Jenkins

Deploys with Jenkins are in most cases registered automatically. Add the pipeline parameter teamName to group deploys for an application under your team.

Spring Boot

Jenkinsfile
@Library('gje-pipeline-library@master') _

pipelineSpringBootAppsGithub {
teamName = 'your-team-name'
// Other parameters
}

Javascript

Jenkinsfile
@Library('gje-pipeline-library@master') _

pipelineJsApps {
teamName = 'your-team-name'
// Other parameters
}

Custom pipeline

def commands = new no.gjensidige.pipeline.Commands()

def appName = "your-app"
def type = "js" // Select "js", "app" or "war"
def teamName = "your-team-name"
def environment = "test" // Select "dev", "test" or "prod"
def serverGroup = "groupb" // Refer to Heimdall server groups
def deployUser = "your-identity"

commands.registerDeployNew(appName, type, teamName, environment, serverGroup, deployUser)

Other CI/CD systems

The deployment registration service is API driven to support any CI/CD system. Contact Team Platform at #team-platform to get API credentials and start registering your deployments 🚀