Plexalyzer Workflow Integration by Plexicus #6
56
.gitea/workflows/plexalyzer-scan.yml
Normal file
56
.gitea/workflows/plexalyzer-scan.yml
Normal file
@ -0,0 +1,56 @@
|
||||
name: PLEXALYZER Analysis
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get Changed Files and Save to File
|
||||
id: get_changed_files
|
||||
shell: bash
|
||||
run: |
|
||||
# Capture changed files and save to a temporary file
|
||||
changed_files=$(git diff --name-only "${{ gitea.event.pull_request.base.sha }}" "${{ gitea.event.pull_request.head.sha }}")
|
||||
echo "$changed_files" | jq -R -s -c 'split("\n")[:-1]' > files_to_scan.json
|
||||
echo "files_path=$(pwd)/files_to_scan.json" >> $GITEA_ENV
|
||||
|
||||
- name: Prepare Files List in Required Format
|
||||
if: ${{ env.files_path }}
|
||||
id: prepare_files
|
||||
shell: bash
|
||||
run: |
|
||||
jq -r '.[]' "$files_path" > files_to_analyze.txt
|
||||
echo "files_to_analyze=$(pwd)/files_to_analyze.txt" >> $GITEA_ENV
|
||||
|
||||
- name: Run PLEXALYZER Docker Analysis
|
||||
shell: bash
|
||||
env:
|
||||
PLEXALYZER_TOKEN: ${{ secrets.PLEXALYZER_TOKEN }}
|
||||
MESSAGE_URL: 'https://api.covulor.dev.plexicus.com/receive_plexalyzer_message'
|
||||
run: |
|
||||
# Run container without mounting the file
|
||||
container_id=$(docker run -d --rm \
|
||||
-e PLEXALYZER_TOKEN="$PLEXALYZER_TOKEN" \
|
||||
-e MESSAGE_URL="$MESSAGE_URL" \
|
||||
plexicus/plexalyzer-dev:latest)
|
||||
|
||||
docker cp "$(pwd)" "$container_id:/mounted_volumes"
|
||||
|
||||
if [ -n "${files_to_analyze}" ]; then
|
||||
docker cp "$(pwd)/files_to_analyze.txt" "$container_id:/app/files_to_analyze.txt"
|
||||
fi
|
||||
|
||||
docker exec "$container_id" /venvs/plexicus-fastapi/bin/python /app/analyze.py \
|
||||
--repository_id "${{ vars.COVULOR_REPO_ID }}" \
|
||||
--name "${{ gitea.repository }}" \
|
||||
--branch "${{ gitea.event.pull_request.base.ref }}" \
|
||||
--url "${{ gitea.event.repository.clone_url }}" \
|
||||
--pr-id "${{ gitea.event.pull_request.number }}" \
|
||||
--no-progress-bar
|
||||
Loading…
Reference in New Issue
Block a user