Skip to content

feat: Add phylum report comment #1

feat: Add phylum report comment

feat: Add phylum report comment #1

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:

Check failure on line 19 in .github/workflows/phylum-analyze.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/phylum-analyze.yml

Invalid workflow file

secret name `github_token` within `workflow_call` can not be used since it would collide with system reserved name
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