CodeScan in Github Actions using the SFDX Plugin
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
- feature/**
jobs:
build:
runs-on: ubuntu-latest
env: # The variables to set for your project and organization
codescan_org: 'your-organization-key'
codescan_project_key: 'project-key'
codescan_token: ${{ secrets.codescan_token }}
steps:
- uses: actions/checkout@v1
- uses: actions/[email protected]
- name: Install SFDX
env:
SFDX_AUTOUPDATE_DISABLE: false
SFDX_USE_GENERIC_UNIX_KEYCHAIN: true
SFDX_DOMAIN_RETRY: 300
SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_CREATE: true
SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE: true
run: |
# Installing the Salesforce CLI
mkdir /tmp/sfdx
wget -q https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz -O /tmp/sfdx/sfdx-linux-amd64.tar.xz
tar xJf /tmp/sfdx/sfdx-linux-amd64.tar.xz -C /tmp/sfdx/ --strip-components 1
/tmp/sfdx/install
# Installing the CodeScan plugin
echo y|sfdx plugins:install sfdx-codescan-plugin
# What to run if a push triggers the build.
- name: Run Codescan On Push
if: github.event_name == 'push'
env:
branch_name: ${{github.ref}}
branch_type: 'LONG'
run: |
sfdx codescan:run --token=$codescan_token --projectkey=$codescan_project_key --organization=$codescan_org -Dsonar.branch.name=${branch_name##*/} -Dsonar.branch.type=$branch_type
# What to run if a pull request triggers the build.
- name: Run Codescan On PR
if: github.event_name == 'pull_request'
env:
branch_name: ${{github.head_ref}}
target: ${{github.base_ref}}
branch_type: SHORT
run: |
sfdx codescan:run --token=$codescan_token --projectkey=$codescan_project_key --organization=$codescan_org -Dsonar.pullrequest.branch=${{github.head_ref}}
-Dsonar.pullrequest.base=${{github.base_ref}} -Dsonar.pullrequest.key=${{github.event.number}}Last updated
Was this helpful?

