-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Upload sonar analysis to Pixee when it is complete and conditionall…
…y trigger PR analysis if it is a PR
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: "Publish Sonar JSON to Pixee" | ||
on: | ||
check_run: | ||
types: [completed] | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
jobs: | ||
publish: | ||
name: "Publish Sonar JSON to Pixee" | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.check_run.name == 'SonarCloud Code Analysis' }} | ||
steps: | ||
- name: "Publish Sonar JSON to Pixee" | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
PR_NUMBER=${{ join(github.event.check_run.pull_requests.*.number, '') }} | ||
URL="https://sonarcloud.io/api/issues/search?componentKeys=pixee_codemodder-python&resolved=false" | ||
if [ -n "$PR_NUMBER" ]; then | ||
URL="${URL}&pullRequest=$PR_NUMBER" | ||
fi | ||
curl -v "$URL" -o sonar_issues.json | ||
cat sonar_issues.json | ||
ANALYSIS_SHA=${{ github.event.check_run.head_sha }} | ||
SECRET=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://app.pixee.ai" | jq -j '.value') | ||
API_RESPONSE=$(curl -v -X PUT -H "Authorization: Bearer $SECRET" -H "Content-Type: multipart/form-data" -F "file=@sonar_issues.json" "https://api.pixee.ai/analysis-input/pixee/codemodder-python/$ANALYSIS_SHA/sonar") | ||
echo "$API_RESPONSE" | ||
- name: "Trigger Pixee Analysis" | ||
if : ${{ toJson(github.event.check_run.pull_requests) != '[]' }} | ||
run: | | ||
SECRET=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://app.pixee.ai" | jq -j '.value') | ||
API_RESPONSE=$(curl -v -X POST -H "Authorization: Bearer $SECRET" "https://api.pixee.ai/analysis-input/pixee/codemodder-python/${{ github.event.check_run.pull_requests[0].number }}") | ||
echo $API_RESPONSE |