feat: Add phylum report comment #1
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: 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: | ||
name: Analyze dependencies with Phylum | ||
permissions: | ||
id-token: write | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- uses: RDXWorks-actions/checkout@main | ||
with: | ||
fetch-depth: 0 | ||
- name: Analyze dependencies | ||
uses: RDXWorks-actions/phylum-analyze-pr-action@main | ||
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 |