jinja2-action icon indicating copy to clipboard operation
jinja2-action copied to clipboard

Doesn't create a file if it doesn't exist already

Open pcgeek86 opened this issue 2 years ago • 1 comments

If the target file doesn't already exist, then this Action throws an exception.

Run cuchi/[email protected]
/usr/bin/docker run --name a682585caf9ec008f4fbaaf8ac6c0d38484c3_bfdb60 --label 6a6825 --workdir /github/workspace --rm -e INPUT_TEMPLATE -e INPUT_OUTPUT_FILE -e INPUT_STRICT -e INPUT_VARIABLES -e INPUT_DATA_FILE -e INPUT_DATA_FORMAT -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/intro-github-actions/intro-github-actions":"/github/workspace" 6a6825:85caf9ec008f4fbaaf8ac6c0d38484c3
Traceback (most recent call last):
  File "/entrypoint.py", line 38, in <module>
    with open(os.environ['INPUT_OUTPUT_FILE'], 'w') as file:
FileNotFoundError: [Errno 2] No such file or directory: '$HOME/.rclone.conf'

pcgeek86 avatar Dec 13 '21 01:12 pcgeek86

Looks like this is actually because the environment variable in the path is not being expanded.

This Q&A seems to have the solution. Use os.path.expandvars.

https://stackoverflow.com/questions/5258647/expanding-environment-variable-in-string-using-python

pcgeek86 avatar Dec 13 '21 01:12 pcgeek86