Update detekt.yml #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Scan with Detekt | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
schedule: | |
- cron: '38 15 * * 4' | |
workflow_dispatch: | |
env: | |
DETEKT_RELEASE_TAG: v1.20.0 # Detekt의 최신 릴리스 태그로 업데이트 | |
jobs: | |
scan: | |
name: Scan | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Install dependencies | |
run: ./gradlew dependencies | |
- name: Get Detekt download URL | |
id: detekt_info | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh api graphql --field tagName=$DETEKT_RELEASE_TAG --raw-field query=' | |
query getReleaseAssetDownloadUrl($tagName: String!) { | |
repository(name: "detekt", owner: "detekt") { | |
release(tagName: $tagName) { | |
releaseAssets(name: "detekt", first: 1) { | |
nodes { | |
downloadUrl | |
} | |
} | |
tagCommit { | |
oid | |
} | |
} | |
} | |
} | |
' > gh_response.json | |
DETEKT_RELEASE_SHA=$(jq --raw-output '.data.repository.release.tagCommit.oid' gh_response.json) | |
if [ $DETEKT_RELEASE_SHA != "37f0a1d006977512f1f216506cd695039607c3e5" ]; then | |
echo "Release tag doesn't match expected commit SHA" | |
exit 1 | |
fi | |
DETEKT_DOWNLOAD_URL=$(jq --raw-output '.data.repository.release.releaseAssets.nodes[0].downloadUrl' gh_response.json) | |
echo "download_url=$DETEKT_DOWNLOAD_URL" >> $GITHUB_OUTPUT | |
- name: Setup Detekt | |
run: | | |
dest=$(mktemp -d) | |
curl --request GET --url ${{ steps.detekt_info.outputs.download_url }} --silent --location --output $dest/detekt | |
chmod a+x $dest/detekt | |
echo $dest >> $GITHUB_PATH | |
- name: Run Detekt | |
continue-on-error: true | |
run: | | |
detekt --input ${{ github.workspace }} --report sarif:${{ github.workspace }}/detekt.sarif.json | |
- name: Make artifact location URIs relative | |
continue-on-error: true | |
run: | | |
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 | |
- uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: ${{ github.workspace }}/detekt.sarif.json | |
checkout_path: ${{ github.workspace }} |