Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract inlined shell script in action to own file #10

Merged
merged 4 commits into from
Mar 12, 2024

Conversation

okize
Copy link
Contributor

@okize okize commented Mar 5, 2024

I tried a couple other things before going with environment variables to pass args into the shell script.

using positional arguments didn't work because in order for the postfix to work, the prefix can't be set and passing an empty string didn't work, so whatever was set for the postfix argument would end up as the prefix.

I tried using single char flags (ie. -f for filename) like this:

bash ${GITHUB_ACTION_PATH}/parse_tool_versions.sh -f ${{ inputs.filename }} -u ${{ inputs.uppercase }} -p ${{ inputs.prefix }} -x ${{ inputs.postfix }} >> $GITHUB_ENV

and in the script:

+while getopts "f:u:p:x" option; do
+case "$option" in
+f) filename=${OPTARG};;
+u) uppercase=${OPTARG};;
+p) prefix=${OPTARG};;
+x) postfix=${OPTARG};;
+*) echo "Invalid option";;
+esac
+done

but faced the same problem... if inputs.prefix was unset, -x would end up being the value passed into -p and so you'd end up with _X_NODEJS etc.

there's probably something better than environment variables but this works

@okize okize force-pushed the mew/extract_into_shell_script branch 9 times, most recently from aafb98c to 85ab3aa Compare March 5, 2024 17:58
@okize okize force-pushed the mew/extract_into_shell_script branch 2 times, most recently from 2ae49fd to e5b4d0d Compare March 5, 2024 18:59
@okize okize force-pushed the mew/extract_into_shell_script branch from e5b4d0d to 733b483 Compare March 5, 2024 19:02
@okize okize marked this pull request as ready for review March 5, 2024 19:02
@okize okize merged commit 463c461 into main Mar 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants