Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathiamu authored Oct 15, 2024
2 parents b73b825 + 66dcebb commit f35fdda
Show file tree
Hide file tree
Showing 11 changed files with 333 additions and 35 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/gcp-build-push-deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Bygg og deploy til dev-gcp
on:
workflow_dispatch:
env:
PRINT_PAYLOAD: true
permissions:
packages: write
contents: write
id-token: write
jobs:
build-and-push:
name: Build and push
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'

- name: Build maven artifacts
run: mvn -B package -D skipTests

- name: Build and push Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: obo
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

deploy-dev:
name: Deploy application to dev-gcp
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy application
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: .nais/application/gcp/application-config-dev.yaml
VAR: image=${{ needs.build-and-push.outputs.image }}
89 changes: 89 additions & 0 deletions .github/workflows/gcp-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "dev", "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "dev" ]
schedule:
- cron: '00 23 * * *'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: "ubuntu-latest"
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java-kotlin' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: maven

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
27 changes: 27 additions & 0 deletions .github/workflows/gcp-deploy-alerts-to-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy alerts for veilarbvedtaksstotte to prod-fss

on:
push:
branches:
- 'master'
paths:
- '.github/workflows/gcp/gcp-deploy-alerts-to-prod.yaml'
- '.nais/alerts/alerts-config-prod.yaml'
workflow_dispatch:
permissions:
packages: write
id-token: write

jobs:
deploy-alerts:
name: Deploy alerts to prod-gcp
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy to prod-gcp
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: .nais/alerts/alerts-config-prod.yaml
44 changes: 44 additions & 0 deletions .github/workflows/gcp-deploy-unleash-apitoken.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy unleash-apitoken
on:
push:
branches:
- dev
- master
- gcp-migration
paths:
- ".github/workflows/gcp/gcp-deploy-unleash-apitoken.yaml"
- ".nais/application/gcp/unleash-apitoken-dev.yaml"
- ".nais/application/gcp/unleash-apitoken-prod.yaml"

jobs:
deploy-dev:
name: Deploy unleash-apitoken to dev-gcp
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy unleash-apitoken
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: .nais/application/gcp/unleash-apitoken-dev.yaml
PRINT_PAYLOAD: true

deploy-prod:
name: Deploy unleash-apitoken to prod
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy unleash-apitoken
uses: nais/deploy/actions/deploy@v2
if: github.ref == 'refs/heads/master'
env:
CLUSTER: prod-gcp
RESOURCE: .nais/application/gcp/unleash-apitoken-prod.yaml
PRINT_PAYLOAD: true
103 changes: 103 additions & 0 deletions .github/workflows/gcp-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Test, build, push and deploy
on: push
env:
IMAGE_TAG: ${{ github.sha }}
PRINT_PAYLOAD: true
permissions:
packages: write
contents: write
id-token: write
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'

- name: Run maven tests
run: mvn -B verify

test-build-and-push:
name: Test, build and push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/gcp-migration'
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'

- name: Build maven artifacts
run: mvn -B package

- name: Build and push Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: obo
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

deploy-dev:
name: Deploy application to dev-gcp
if: github.ref == 'refs/heads/gcp-migration'
needs: test-build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy application
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: .nais/application/gcp/application-config-dev.yaml
VAR: image=${{ needs.test-build-and-push.outputs.image }}

- name: Create release
uses: softprops/action-gh-release@v2
with:
name: Release to dev-gcp
tag_name: release/dev@${{ env.IMAGE_TAG }}
prerelease: true

deploy-prod:
name: Deploy application to prod-gcp
if: github.ref == 'refs/heads/master-gcp'
needs: test-build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy application
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: .nais/application/gcp/application-config-prod.yaml
VAR: image=${{ needs.test-build-and-push.outputs.image }}

- name: Create release
uses: softprops/action-gh-release@v2
with:
name: Release to prod
tag_name: release/prod@${{ env.IMAGE_TAG }}
prerelease: false
25 changes: 1 addition & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
test-build-and-push:
name: Test, build and push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master'
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
permissions:
Expand All @@ -56,29 +56,6 @@ jobs:
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

deploy-dev:
name: Deploy application to dev
if: github.ref == 'refs/heads/dev'
needs: test-build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy application
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-fss
RESOURCE: .nais/application/application-config-dev.yaml
VAR: image=${{ needs.test-build-and-push.outputs.image }}

- name: Create release
uses: softprops/action-gh-release@v2
with:
name: Release to dev
tag_name: release/dev@${{ env.IMAGE_TAG }}
prerelease: true

deploy-prod:
name: Deploy application to prod
if: github.ref == 'refs/heads/master'
Expand Down
4 changes: 2 additions & 2 deletions .nais/application/application-config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ spec:
path: veilarbvedtaksstotte/internal/health/liveness
initialDelay: 30
replicas:
min: 1
max: 2
min: 0
max: 0
cpuThresholdPercentage: 75
resources:
limits:
Expand Down
Loading

0 comments on commit f35fdda

Please sign in to comment.