-
Notifications
You must be signed in to change notification settings - Fork 10
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
[FR]: Providing working-directory as an input param #98
Merged
Templum
merged 13 commits into
Templum:main
from
yudintsevegor:feature-add-github-workdir-input-param
Jan 6, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f9151ae
feat: working-directory as an input param
yudintsevegor 86e82db
fix description
yudintsevegor 7ae41bf
Merge branch 'main' into feature-add-github-workdir-input-param
yudintsevegor d7b43c8
remove sh script, provide go file with tests
yudintsevegor b247fd2
remove sh script, provide go file with tests
yudintsevegor 05559e6
Revert "remove sh script, provide go file with tests"
yudintsevegor ed50992
revert back to sh script
yudintsevegor f7b0e70
fox description
yudintsevegor 77a5141
some debug
yudintsevegor 3a825c8
debug
yudintsevegor 6d21ed8
debug 3
yudintsevegor a2d120b
return back
yudintsevegor 1934c7d
remove debug
yudintsevegor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
github_workspace=$1 | ||
input_working_directory=$2 | ||
|
||
if [ -z $github_workspace ]; then | ||
echo "The first argument (github.workspace) is required."; | ||
exit 1; | ||
elif [[ $github_workspace = $input_working_directory || -z $input_working_directory ]]; then | ||
export DOCKER_WD=$github_workspace; | ||
export GITHUBH_WD=$github_workspace; | ||
elif [[ $input_working_directory =~ ^/ ]]; then | ||
export DOCKER_WD=$input_working_directory; | ||
export GITHUBH_WD=.$input_working_directory; | ||
else | ||
export DOCKER_WD=$(echo $input_working_directory | sed 's/\.//'); | ||
export GITHUBH_WD=$input_working_directory | ||
fi | ||
|
||
echo "export DOCKER_WD=$DOCKER_WD" | ||
echo "export GITHUBH_WD=$GITHUBH_WD" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be so kind to walk me through your code here ?
I see that
DOCKER_WD
&GITHUBH_WD
in the most cases have the same contentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sure!
The content is not exactly the same. Let me provide more details, which could simply the understanding:
github.worspace
is empty --> the execution is not possible. The reason for that is to be sure that the first argument isgithub.worspace
as we use it as a default case.github_workspace
==input_working_directory
OR theinput_working_directory
== "" (as a second arg) we could usegithub_workspace
as a default use case.if 2 args are provided, we could forget about
github_workspace
and useinput_working_directory
for our processing:input_working_directory
starts with/
then for the docker we would use it as it is (docker accepts only absolute paths), but for the github workdir we would need to add a dot as a prefix:./
(GitHub working-directory should be relative path)input_working_directory
starts with./
then for the docker we would remove a dot from the beginning with a help ofsed
command (docker accepts only absolute paths) and useinput_working_directory
as it is for the github actions (GitHub working-directory should be relative path)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This morning I tried to implement it in Go with tests (you could see commits below), but I gave up this idea because it's not possible to set the env variable from the go program to use it outside of it. I guess it could be a workaround, but probably with
sh
script is cleanerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, probably having a shell script is fine for this case. I also don't think any extra test needs to be done. The E2E Flow that we have in place, should be sufficient enough.