Skip to content

Add default working directory to codacy security test #21

Add default working directory to codacy security test

Add default working directory to codacy security test #21

Workflow file for this run

name: Codacy Security Scan
on:
push:
branches: [ "main" ]
paths:
- 'src/**.php'
- '.github/workflows/codacy.yml'
pull_request:
branches: [ "main" ]
paths:
- 'src/**.php'
- '.github/workflows/codacy.yml'
# schedule:
# - cron: '45 15 * * 1'
defaults:
run:
working-directory: src
concurrency:
group: "${{ github.workflow_ref }}-${{ github.ref }}-${{ matrix.php-version }}-${{ matrix.node-version }}-${{ matrix.os }}"

Check failure on line 22 in .github/workflows/codacy.yml

View workflow run for this annotation

GitHub Actions / Codacy Security Scan

Invalid workflow file

The workflow is not valid. .github/workflows/codacy.yml (Line: 22, Col: 10): Unrecognized named-value: 'matrix'. Located at position 1 within expression: matrix.php-version
cancel-in-progress: true
jobs:
codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
strategy:
matrix:
php-version: [8.3]
node-version: [current]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
name: Codacy Security Scan with PHP ${{ matrix.php-version }} on ${{ matrix.os }}
env:
php-extensions: intl, pcov
php-coverage: pcov
steps:
- name: Checkout
uses: actions/checkout@v4
- name: PHP extensions cache
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.php-extensions }}
key: vl-${{ matrix.os }}-php${{ matrix.php-version }}-node${{ matrix.node-version }}-${{ hashFiles('composer.json', 'composer.lock', 'package.json', 'package.lock') }}
- name: Get Composer cache directory
id: composer-cache
run: |
composer validate
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/[email protected]
with:
path: |
${{ steps.extcache.outputs.dir }}
${{ steps.composer-cache.outputs.dir }}
src/vendor
src/node_modules
key: ${{ steps.extcache.outputs.key }}
restore-keys: vl-${{ matrix.os }}-php${{ matrix.php-version }}-
- name: Setup PHP
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.php-extensions }}
coverage: ${{ env.php-coverage }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'src'
- name: Install Node/PHP dependencies
run: |
composer self-update && composer install --no-interaction --no-progress --no-scripts --prefer-dist -vv
composer dump-autoload
npm install
npm run build
- name: Prepare Env.
run: |
# Copy .env, Generate key, Set directory permissions, Create empty SQLite DB
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
chmod -R 777 storage storage/database bootstrap/cache
mkdir -p storage/database
rm -f storage/database/visual-laravel.sqlite
touch storage/database/visual-laravel.sqlite
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif