Update action.yml
This commit is contained in:
parent
f7ce5f1ff9
commit
619e8043be
66
action.yml
66
action.yml
@ -8,67 +8,49 @@ 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
|
||||||
|
|
||||||
- name: Prepare Files List in Required Format
|
- name: Prepare Files List in Required Format
|
||||||
if: ${{ env.files_path }}
|
if: ${{ env.files_path }}
|
||||||
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
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
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.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\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker_command+=" plexicus/plexalyzer-dev:latest \
|
|
||||||
/venvs/plexicus-fastapi/bin/python /app/analyze.py \
|
|
||||||
--repository_id \"${{ vars.COVULOR_REPO_ID }}\" \
|
|
||||||
--name \"${{ GITEA_REPO_NAME }}\" \
|
|
||||||
--branch \"${{ GITEA_BRANCH }}\" \
|
|
||||||
--url \"${{ GITEA_REPO_URL }}\" \
|
|
||||||
--no-progress-bar"
|
|
||||||
|
|
||||||
if [ -n "${{ GITEA_REPO_OWNER }}" ]; then
|
if [ -n "${files_to_analyze}" ]; then
|
||||||
docker_command+=" --owner \"${{ GITEA_REPO_OWNER }}\""
|
docker cp "$(pwd)/files_to_analyze.txt" "$container_id:/app/files_to_analyze.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$(pwd)/files_to_analyze.txt" ]; then
|
docker exec "$container_id" /venvs/plexicus-fastapi/bin/python /app/analyze.py \
|
||||||
docker_command+=" --files \"/app/files_to_analyze.txt\""
|
--repository_id "${{ vars.COVULOR_REPO_ID }}" \
|
||||||
fi
|
--name "${{ gitea.repository }}" \
|
||||||
|
--branch "${{ gitea.event.pull_request.base.ref }}" \
|
||||||
analysis_output=$(eval $docker_command || true)
|
--url "${{ gitea.event.repository.clone_url }}" \
|
||||||
docker_exit_code=$?
|
--pr-id "${{ gitea.event.pull_request.number }}" \
|
||||||
|
--no-progress-bar
|
||||||
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
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user