Skip to content

Commit

Permalink
gradlew 8.2.1, dep. sbom, bump deps, dev+prodrelease workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
olesls committed Aug 7, 2023
1 parent 9d1f5f5 commit b5a4ed3
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 223 deletions.
91 changes: 30 additions & 61 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# 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: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '43 16 * * 4'
branches:
- main
- deps0408

jobs:
codeql-analyze:
Expand All @@ -29,48 +15,31 @@ jobs:
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' 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@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
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.

# 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, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ 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@v2
with:
category: "/language:${{matrix.language}}"
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: java
queries: security-and-quality

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Build application
run: ./gradlew clean build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:java"
112 changes: 112 additions & 0 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: deploy-dev

on:
push:
branches:
- main
- deps-0408

jobs:
build:
name: Build app, docker image and push docker image
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- uses: gradle/[email protected]
env: # Eksluder test dependencies
DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS: compileClasspath|runtimeClasspath
TESTCONTAINERS_RYUK_DISABLED: true
with:
dependency-graph: generate-and-submit
arguments: build

- name: Pre-deploy
uses: navikt/digihot-deploy/actions/pre-deploy@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
byosbom: dependency-graph-reports/deploy-dev-build.json
team: teamdigihot
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
tag: ${{ env.VERSION_TAG }}

- name: Deploy to dev-gcp
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais/nais-dev.yaml,nais/alerts.yaml
IMAGE: ${{steps.docker-build-push.outputs.image}}

- name: post-deploy
if: github.ref == 'refs/heads/main'
uses: navikt/digihot-deploy/actions/post-deploy@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: draft release
if: github.ref == 'refs/heads/main'
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION_TAG }}
release_name: ${{ env.APPLICATION }} ${{ env.VERSION_TAG }}
body: ${{ env.CHANGE_LOG }}
draft: true
prerelease: false

outputs:
image: ${{ steps.docker-build-push.outputs.image }}

trivy-imagescan:
name: Scan dockerimage with Trivy
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read
id-token: write
steps:
- uses: nais/login@v0
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: teamdigihot

- name: Run Trivy vulnerability scanner on docker image
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ needs.build.outputs.image }}
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
43 changes: 43 additions & 0 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: deploy-prod
on:
release:
types: [ published ]

jobs:
deploy-prod:
permissions:
contents: "write"
id-token: "write"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: nais/login@v0
name: get image registry
id: nais-login
with:
team: teamdigihot
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

- name: get image
env:
VERSION_TAG: ${{ github.event.release.tag_name }}
REGISTRY: ${{ steps.nais-login.outputs.registry }}
APP: ${{ github.event.repository.name }}
run: |
IMAGE=$REGISTRY/$APP:$VERSION_TAG
echo "IMAGE=${IMAGE}" >> $GITHUB_ENV
echo $IMAGE
- uses: nais/deploy/actions/deploy@v1
name: deploy to prod-gcp
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/nais-prod.yaml,nais/alerts-prod.yaml

- name: post-production
uses: navikt/digihot-deploy/actions/post-production@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 1 addition & 28 deletions .github/workflows/detekt-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,19 @@
# This workflow performs a static analysis of your Kotlin source code using
# Detekt.
#
# Scans are triggered:
# 1. On every push to default and protected branches
# 2. On every Pull Request targeting the default branch
# 3. On a weekly schedule
# 4. Manually, on demand, via the "workflow_dispatch" event
#
# The workflow should work with no modifications, but you might like to use a
# later version of the Detekt CLI by modifing the $DETEKT_RELEASE_TAG
# environment variable.
name: Scan with Detekt

on:
# Triggers the workflow on push or pull request events but only for default and protected branches
push:
branches: [ main, detekt-config-2 ]
pull_request:
branches: [ main ]
schedule:
- cron: '16 23 * * 3'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
# Release tag associated with version of Detekt to be installed
# SARIF support (required for this workflow) was introduced in Detekt v1.15.0
DETEKT_RELEASE_TAG: v1.15.0

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "scan"
detekt-scan:
name: Scan
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Gets the download URL associated with the $DETEKT_RELEASE_TAG
- name: Get Detekt download URL
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/monitor-dependencies.yml

This file was deleted.

Loading

0 comments on commit b5a4ed3

Please sign in to comment.