I am trying to run detekt only on changed files in a pull request. The following doesn't work when I try to pass CHANGED_FILES as an argument to the input parameter for detekt.
# This workflow performs a static analysis of your Kotlin source code using
# Detekt.
#
# Scans are triggered:
# 1. On every push to the main branch
# 2. On every Pull Request targeting the main branch
name: detekt
## 2
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Triggers the workflow on push or pull request events but only for default and protected branches
push:
branches:
- main
pull_request:
branches:
- main
# 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 "detekt"
detekt:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: "checkout"
uses: actions/checkout@v3
# Determines changed files
- name: "changed_files"
run: |
git fetch origin main:refs/remotes/origin/main
export CHANGED_FILES=$(git --no-pager diff --name-only origin/main HEAD | tr '\n' ',' | sed 's/\(.*\),/\1 /')
echo "Changed files: $CHANGED_FILES"
- name: "detekt-all"
uses: natiginfo/[email protected]
env:
CHANGED_FILES: ${{ CHANGED_FILES }}
with:
args: --fail-fast --config detekt-config.yml --plugins detekt/detekt-formatting-1.21.0.jar --input $CHANGED_FILES
I get this error:
Exception in thread "main" com.beust.jcommander.ParameterException: Provided path '$CHANGED_FILES' does not exist!
I tried multiple other ways, but to no avail. I'm not familiar with YAML and I'm trying to figure out the correct syntax to do this, but I could not find any guidance about this specifically. How do we correctly pass it as an argument to a parameter instead of it being taken as the path itself? If I'm going about this the wrong way, then please let me know how to achieve this differently.