Skip to content

ci(detekt): fix move of jar #27

ci(detekt): fix move of jar

ci(detekt): fix move of jar #27

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# 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: Vulnerability Scan with Detekt
on:
# Triggers the workflow on push or pull request events but only for default and protected branches
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '25 6 * * 1'
# 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: "1.23.4"
DETEKT_FILE_NAME: "detekt-cli-${DETEKT_VERSION}-all.jar"
DETEKT_URL: "https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/${DETEKT_FILE_NAME}"
# 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"
scan:
name: Detekt Scan
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Sets up JDK
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repository
uses: actions/checkout@v4
# Sets up the detekt cli
- name: Setup Detekt
run: |
dest=$( mktemp -d )
curl --request GET \
--url ${DETEKT_URL} \
--silent \
--location \
--output $dest/${DETEKT_FILE_NAME}
mv $dest/${DETEKT_FILE_NAME} $dest/detekt.jar
# Performs static analysis using Detekt
- name: Run Detekt
continue-on-error: true
run: |
java -jar $dest/detekt.jar --input ${{ github.workspace }} --report sarif:${{ github.workspace }}/detekt.sarif.json
# Modifies the SARIF output produced by Detekt so that absolute URIs are relative
# This is so we can easily map results onto their source files
# This can be removed once relative URI support lands in Detekt: https://git.io/JLBbA
- name: Make artifact location URIs relative
continue-on-error: true
run: |
echo "$(
jq \
--arg github_workspace ${{ github.workspace }} \
'. | ( .runs[].results[].locations[].physicalLocation.artifactLocation.uri |= if test($github_workspace) then .[($github_workspace | length | . + 1):] else . end )' \
${{ github.workspace }}/detekt.sarif.json
)" > ${{ github.workspace }}/detekt.sarif.json
# Sets up the reviewdog cli
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
- name: Show reviewdog version
run: reviewdog -version
- name: Run reviewdog
run: reviewdog -f=sarif -diff="git diff" -name="detekt" < ${{ github.workspace }}/detekt.sarif.json
# Uploads results to GitHub repository using the upload-sarif action
- uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: ${{ github.workspace }}/detekt.sarif.json
checkout_path: ${{ github.workspace }}