sfdx-scan-pull-request icon indicating copy to clipboard operation
sfdx-scan-pull-request copied to clipboard

Handle actions triggered by PR comments

Open scottbcovert opened this issue 11 months ago • 1 comments

Closes #75

scottbcovert avatar Mar 11 '24 18:03 scottbcovert

Here is a sample Github action workflow to demonstrate how the new inputs would work when the action initiates from someone posting a comment to the PR that contains /scan in the body.

name: Code Analyzer
on:
    issue_comment: # Note: This event will only trigger a workflow run if the workflow file is on the default branch.
        types: [created]
jobs:
    analyze_manual:
        if: github.event.issue.pull_request && contains(github.event.comment.body, '/scan')
        runs-on: ubuntu-latest
        container: salesforce/cli:latest-full
        steps:
            - uses: actions/checkout@v3
              with:
                  fetch-depth: 0
                  ref: refs/pull/${{ github.event.issue.number }}/head

            - run: git config --system --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}

            - uses: xt0rted/pull-request-comment-branch@v2
              id: comment-branch

            - name: Run SFDX Scanner - Report findings as comments
              uses: tythonco/[email protected] # Temp action for testing
              with:
                  engine: 'pmd-appexchange'
                  head: ${{ steps.comment-branch.outputs.head_ref }}
                  head-sha: ${{ steps.comment-branch.outputs.head_sha }}
                  base: ${{ steps.comment-branch.outputs.base_ref }}
              env:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scottbcovert avatar Mar 11 '24 18:03 scottbcovert