Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 619e8043be | |||
| f7ce5f1ff9 | |||
| b8d65c1aeb |
62
action.yml
62
action.yml
@ -8,17 +8,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git clone $GITEA_REPO_URL .
|
||||
git fetch --all
|
||||
git reset --hard $GITEA_COMMIT_SHA
|
||||
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_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 "files_path=$(pwd)/files_to_scan.json" >> $GITEA_ENV
|
||||
|
||||
@ -27,48 +26,31 @@ jobs:
|
||||
id: prepare_files
|
||||
shell: bash
|
||||
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
|
||||
|
||||
- name: Run PLEXALYZER Docker Analysis
|
||||
shell: bash
|
||||
env:
|
||||
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: |
|
||||
# Construct the Docker command
|
||||
docker_command="docker run --rm \
|
||||
-e PLEXALYZER_TOKEN=\"$PLEXALYZER_TOKEN\" \
|
||||
-e MESSAGE_URL=\"$MESSAGE_URL\" \
|
||||
-v \"${{ GITEA_WORKSPACE }}:/mounted_volumes\""
|
||||
# Run container without mounting the file
|
||||
container_id=$(docker run -d --rm \
|
||||
-e PLEXALYZER_TOKEN="$PLEXALYZER_TOKEN" \
|
||||
-e MESSAGE_URL="$MESSAGE_URL" \
|
||||
plexicus/plexalyzer:latest)
|
||||
|
||||
if [ -f "$(pwd)/files_to_analyze.txt" ]; then
|
||||
docker_command+=" -v \"$(pwd)/files_to_analyze.txt:/app/files_to_analyze.txt\""
|
||||
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_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
|
||||
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
|
||||
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