diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/Dockerfile b/Dockerfile index 4adbf55..776f6c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,19 @@ FROM python:3.8-slim # Set the working directory in the container -WORKDIR /usr/src/app +WORKDIR /github/workspace # Copy the script and the templates directory into the container -COPY markmysamm.py ./ -COPY templates/ ./templates/ +COPY requirements.txt /requirements.txt +COPY markmysamm.py /markmysamm.py +COPY templates/ /templates/ +RUN ls -la # Install any needed packages specified in requirements.txt # You should create a requirements.txt file if you have external dependencies -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r /requirements.txt # Run markmysamm.py when the container launches -ENTRYPOINT ["python3", "markmysamm.py"] \ No newline at end of file +#ENTRYPOINT ["python3", "/markmysamm.py"] +# Temporarily replace the entrypoint for debugging +ENTRYPOINT ["sh", "-c", "echo Current directory: $(pwd) && echo Directory contents: $(ls -la) && echo fr contents: $(ls -la fr) && python3 /markmysamm.py $0 $@"] \ No newline at end of file diff --git a/action.yml b/action.yml index ce6acb7..96d95fb 100644 --- a/action.yml +++ b/action.yml @@ -11,7 +11,5 @@ runs: using: 'docker' image: 'Dockerfile' args: - - '-i' - - ${{ inputs.input_directory }} - - '-o' - - ${{ inputs.output_directory }} \ No newline at end of file + - '-i ${{ inputs.input_directory }}' + - '-o ${{ inputs.output_directory }}' \ No newline at end of file diff --git a/markmysamm.py b/markmysamm.py index 3142d6c..70c11de 100644 --- a/markmysamm.py +++ b/markmysamm.py @@ -67,10 +67,10 @@ def process_template_content(input_file, variables): """ Reads a Markdown template file, replaces placeholders with actual values, and returns content. - :param input_file: path to the input template file + :param input_file: path to the input template file. Relative to this script's location :param variables: a dictionary where keys are placeholder names and values are the actual values """ - with open(input_file, 'r') as file: + with open(os.path.dirname(os.path.abspath(__file__)) + input_file, 'r') as file: template = file.read() return template.format(**variables) @@ -80,8 +80,8 @@ def process_template(input_file, output_file, variables): """ Reads a Markdown template file, replaces placeholders with actual values, and writes to a new file. - :param input_file: path to the input template file - :param output_file: path to the output file + :param input_file: path to the input template file (relative to this script's location) + :param output_file: path to the output file (relative to working directory) :param variables: a dictionary where keys are placeholder names and values are the actual values """ print('[+] Writing file: '+output_file) @@ -300,10 +300,13 @@ def fix_bool(variable): criteria += '- '+critvalue+'\n' # Now get answer set answer_set_markdown = '' - for asetkey,asetvalue in nested_dict['answer_sets'].items(): - if asetvalue['id'] == answer_set_id: - for ansvalue in asetvalue['values']: - answer_set_markdown += '- '+fix_bool(ansvalue['text'])+'\n' + try: + for asetkey,asetvalue in nested_dict['answer_sets'].items(): + if asetvalue['id'] == answer_set_id: + for ansvalue in asetvalue['values']: + answer_set_markdown += '- '+fix_bool(ansvalue['text'])+'\n' + except Exception as err: + print("Error handling answer sets: ", err) # Set variables for the stream level template variables = {