Skip to content

Commit

Permalink
feat: Add phylum report comment
Browse files Browse the repository at this point in the history
  • Loading branch information
alpeto9 committed Jun 17, 2024
1 parent b1b6c24 commit 97872ee
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/phylum-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@ name: Phylum analyze

on:
workflow_call:
inputs:
phylum_pr_number:
required: false
phylum_pr_name:
required: false
phylum_project_id:
required: false
phylum_group_name:
required: false
github_repository:
required: false
secrets:
phylum_api_key:
required: true
github_token:
required: false

jobs:
phylum_analyze:
Expand All @@ -24,3 +37,22 @@ jobs:
with:
phylum_token: ${{ secrets.phylum_api_key }}
cmd: phylum-ci -vv --force-analysis --all-deps --skip-comments
- name: Post Phylum Report Comment
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
REPO: ${{ inputs.github_repository }}
PR_NUMBER: ${{ inputs.phylum_pr_number }}
BRANCH_NAME: ${{ inputs.phylum_pr_name }}
PHYLUM_ID: ${{ inputs.phylum_project_id }}
PHYLUM_GROUP_NAME: ${{ inputs.phylum_group_name }}
run: |
COMMENT_TITLE="Phylum Report"
COMMENT_BODY="https://app.phylum.io/projects/${PHYLUM_ID}?label=GitHub-Actions_PR%23${PR_NUMBER}_${BRANCH_NAME}&group=${PHYLUM_GROUP_NAME}"
# Check if a comment already exists and update it
EXISTING_COMMENT_ID=$(gh api repos/${REPO}/issues/${PR_NUMBER}/comments | jq -r '.[] | select(.body | contains("Phylum Report")) | .id')
if [ -n "$EXISTING_COMMENT_ID" ]; then
gh api repos/${REPO}/issues/comments/${EXISTING_COMMENT_ID} -X PATCH -f body="${COMMENT_BODY}"
else
gh api repos/${REPO}/issues/${PR_NUMBER}/comments -f body="${COMMENT_TITLE}\n\n${COMMENT_BODY}"
fi

0 comments on commit 97872ee

Please sign in to comment.