Skip to content

Commit

Permalink
Provide the proper env for the script #6
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Apr 25, 2024
1 parent 870a8db commit 9bd551f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-to-dejacode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
env:
DEJACODE_URL: ${{ secrets.DEJACODE_URL }}
DEJACODE_API_KEY: ${{ secrets.DEJACODE_API_KEY }}
PROJECT_OUTPUTS: ${{ env.PROJECT_OUTPUTS }}
PROJECT_OUTPUT_DIRECTORY: ${{ env.PROJECT_OUTPUT_DIRECTORY }}
8 changes: 5 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ runs:
project_status=$(scanpipe status --project ${{ inputs.project-name }})
work_directory=$(echo "$project_status" | grep -oP 'Work directory:\s*\K[^\n]+')
echo "PROJECT_WORK_DIRECTORY=$work_directory" >> $GITHUB_ENV
echo "PROJECT_INPUT_DIRECTORY=$work_directory/input" >> $GITHUB_ENV
echo "PROJECT_OUTPUT_DIRECTORY=$work_directory/output" >> $GITHUB_ENV
- name: Copy input files to project work directory
shell: bash
run: |
SOURCE_PATH="${{ inputs.inputs-path }}"
DESTINATION_PATH="${{ env.PROJECT_WORK_DIRECTORY }}/input/"
DESTINATION_PATH="${{ env.PROJECT_INPUT_DIRECTORY }}"
if [ -d "$SOURCE_PATH" ]; then
cp -r "$SOURCE_PATH"/* "$DESTINATION_PATH"
fi
Expand All @@ -106,12 +108,12 @@ runs:
scanpipe output --no-color \
--project ${{ inputs.project-name }} \
--format ${{ inputs.output-formats }}
project_outputs=$(ls ${{ env.PROJECT_WORK_DIRECTORY }}/output/))
project_outputs=$(ls ${{ env.PROJECT_OUTPUT_DIRECTORY }}))
echo "PROJECT_OUTPUTS=$project_outputs" >> $GITHUB_ENV
- name: Upload outputs
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: ${{ inputs.outputs-archive-name }}
path: ${{ env.PROJECT_WORK_DIRECTORY }}/output/*
path: ${{ env.PROJECT_OUTPUT_DIRECTORY }}/*
7 changes: 4 additions & 3 deletions scripts/push_to_dejacode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Visit https://github.com/nexB/scancode.io for support and download.

from pathlib import Path
import uuid
import requests
import os

Expand Down Expand Up @@ -68,13 +69,13 @@ def push_scan_to_product(files):
if __name__ == "__main__":
product_data = {
"name": "Demo Push Product",
"version": "1.0",
"version": uuid.uuid4(),
}
product_uuid = create_product(product_data)

# Replace by args
PROJECT_OUTPUTS = os.environ["PROJECT_OUTPUTS"]
scan_location = list(Path(PROJECT_OUTPUTS).glob("*.json"))[0]
PROJECT_OUTPUT_DIRECTORY = os.environ["PROJECT_OUTPUT_DIRECTORY"]
scan_location = list(Path(PROJECT_OUTPUT_DIRECTORY).glob("*.json"))[0]
print(scan_location)

files = {"upload_file": open(scan_location, "rb")}
Expand Down

0 comments on commit 9bd551f

Please sign in to comment.