Update action.yml

This commit is contained in:
tmalbos.pl 2025-03-01 15:51:45 +01:00
parent 9c0598f551
commit 5fb6bd0db5

View File

@ -8,17 +8,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
run: | uses: actions/checkout@v4
git clone $GITEA_REPO_URL . with:
git fetch --all fetch-depth: 0
git reset --hard $GITEA_COMMIT_SHA
- name: Get Changed Files and Save to File - name: Get Changed Files and Save to File
id: get_changed_files id: get_changed_files
shell: bash shell: bash
run: | run: |
# Capture changed files and save to a temporary file # Capture changed files and save to a temporary file
changed_files=$(git diff --name-only "${GITEA_BASE_SHA}" "${GITEA_HEAD_SHA}") 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 "$changed_files" | jq -R -s -c 'split("\n")[:-1]' > files_to_scan.json
echo "files_path=$(pwd)/files_to_scan.json" >> $GITEA_ENV echo "files_path=$(pwd)/files_to_scan.json" >> $GITEA_ENV
@ -27,7 +26,7 @@ jobs:
id: prepare_files id: prepare_files
shell: bash shell: bash
run: | run: |
jq -r '.[]' "${env.files_path}" > files_to_analyze.txt jq -r '.[]' "$files_path" > files_to_analyze.txt
echo "files_to_analyze=$(pwd)/files_to_analyze.txt" >> $GITEA_ENV echo "files_to_analyze=$(pwd)/files_to_analyze.txt" >> $GITEA_ENV
- name: Run PLEXALYZER Docker Analysis - name: Run PLEXALYZER Docker Analysis
@ -36,39 +35,22 @@ jobs:
PLEXALYZER_TOKEN: ${{ secrets.PLEXALYZER_TOKEN }} PLEXALYZER_TOKEN: ${{ secrets.PLEXALYZER_TOKEN }}
MESSAGE_URL: 'https://api.covulor.dev.plexicus.com/receive_plexalyzer_message' MESSAGE_URL: 'https://api.covulor.dev.plexicus.com/receive_plexalyzer_message'
run: | run: |
# Construct the Docker command # Run container without mounting the file
docker_command="docker run --rm \ container_id=$(docker run -d --rm \
-e PLEXALYZER_TOKEN=\"$PLEXALYZER_TOKEN\" \ -e PLEXALYZER_TOKEN="$PLEXALYZER_TOKEN" \
-e MESSAGE_URL=\"$MESSAGE_URL\" \ -e MESSAGE_URL="$MESSAGE_URL" \
-v \"${{ GITEA_WORKSPACE }}:/mounted_volumes\"" plexicus/plexalyzer:latest)
if [ -f "$(pwd)/files_to_analyze.txt" ]; then docker cp "$(pwd)" "$container_id:/mounted_volumes"
docker_command+=" -v \"$(pwd)/files_to_analyze.txt:/app/files_to_analyze.txt\""
if [ -n "${files_to_analyze}" ]; then
docker cp "$(pwd)/files_to_analyze.txt" "$container_id:/app/files_to_analyze.txt"
fi fi
docker_command+=" plexicus/plexalyzer-dev:latest \ docker exec "$container_id" /venvs/plexicus-fastapi/bin/python /app/analyze.py \
/venvs/plexicus-fastapi/bin/python /app/analyze.py \ --repository_id "${{ vars.COVULOR_REPO_ID }}" \
--repository_id \"${{ vars.COVULOR_REPO_ID }}\" \ --name "${{ gitea.repository }}" \
--name \"${{ GITEA_REPO_NAME }}\" \ --branch "${{ gitea.event.pull_request.base.ref }}" \
--branch \"${{ GITEA_BRANCH }}\" \ --url "${{ gitea.event.repository.clone_url }}" \
--url \"${{ GITEA_REPO_URL }}\" \ --pr-id "${{ gitea.event.pull_request.number }}" \
--no-progress-bar" --no-progress-bar
if [ -n "${{ GITEA_REPO_OWNER }}" ]; then
docker_command+=" --owner \"${{ GITEA_REPO_OWNER }}\""
fi
if [ -f "$(pwd)/files_to_analyze.txt" ]; then
docker_command+=" --files \"/app/files_to_analyze.txt\""
fi
analysis_output=$(eval $docker_command || true)
docker_exit_code=$?
echo "$analysis_output" > analysis_results.json
echo "findings_output=$(pwd)/analysis_results.json" >> $GITEA_ENV
echo "Docker command exit code: $docker_exit_code"
if [ $docker_exit_code -ne 0 ]; then
echo "WARNING: Docker command failed with exit code $docker_exit_code."
fi