Skip to content

Instantly share code, notes, and snippets.

@tcampbPPU
Created February 2, 2022 22:56
Show Gist options
  • Save tcampbPPU/90e54fb599e2da9badf2025ef07a0974 to your computer and use it in GitHub Desktop.
Save tcampbPPU/90e54fb599e2da9badf2025ef07a0974 to your computer and use it in GitHub Desktop.
A GitHub action for detecting debugger statements
name: Detect Debug
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, review_requested]
jobs:
changedfiles:
runs-on: ubuntu-latest
# map a step output to a job output
outputs:
vue: ${{ steps.changes.outputs.vue }}
php: ${{ steps.changes.outputs.php }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
# the following lines are needed to get changed file names
with:
fetch-depth: 2
- name: Get changed files
id: changes
run: |
echo "::set-output name=vue::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .vue$ | xargs)"
echo "::set-output name=php::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .php$ | xargs)"
searchconsole:
runs-on: ubuntu-latest
needs: changedfiles
if: ${{ needs.changedfiles.outputs.vue != '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Search for console.log
run: |
message="console.log function call found in new committed code"
for f in $files
do
if egrep 'console.log' -q $f
then
echo "::error file=$f::$message"
fi
done
env:
files: ${{ needs.changedfiles.outputs.vue }}
searchray:
runs-on: ubuntu-latest
needs: changedfiles
if: ${{ needs.changedfiles.outputs.php != '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Search for ray
run: |
message="ray function call found in new committed code"
for f in $files
do
if egrep 'ray(' -q $f
then
echo "::error file=$f::$message"
fi
done
env:
files: ${{ needs.changedfiles.outputs.php }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment