-
Notifications
You must be signed in to change notification settings - Fork 0
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
make the shell configurable (default to bash) #8
Conversation
This PR doesn't work. It looks like we can't specify the shell here using variables. It seems like only strings are allowed (although this isn't properly documented). |
action.yml
Outdated
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- shell: bash | ||
- shell: ${{ inputs.shell }} |
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 seems to be a composite action restriction actions/runner#835. There's a hack/workaround in the issue we might be able to leverage (e.g. creating a file or symlink on the OS which proxies to our shell)
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.
That's annoying. multiple-go-modules
was supposed to be a fairly independent action, I'd hate to couple it that tightly to the rest of our shell logic.
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.
I thought that alternatively, we could duplicate the step here and add an if: ${{ inputs.shell == 'bash' }}
to if: ${{ inputs.shell == 'msys2' }}
to each step, respectively, but that doesn't work either. Apparently, you can't use if
in an Action.
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.
After thinking about this for a bit, maybe the hack that issue is not that terrible.
I modified the PR, and we're now checking not for the OS, but for ${{ inputs.shell }}
. That makes this action (at least a little bit) more general purpose.
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.
We can make it more general purpose if we need to by making a bash script that forwards the command along. Essentially making the yaml point at custom-shell {0}
and making a script called custom-shell that just takes its arguments and forwards them to whatever the shell name in inputs.shell is.
472bd2d
to
4e3a8ef
Compare
3aeebb7
to
8088877
Compare
efbb214
to
c64d0ce
Compare
I simplified the setup a bit by using - shell: bash
if: inputs.shell == 'bash'
working-directory: ${{ inputs.working-directory }}
run: |
<code> once for @mvdan @aschmahmann Can you take another look? |
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.
Took me a minute to understand what the symlink code is doing, but I agree with the approach :)
What's with the {0}
by the way? Ideally we'd strip that, especially given the weird characters and the space.
That would be nice, but I think I tried this at some point, and it didn't work. Also, it seems to be the standard way of doing this, see for example https://github.com/msys2/setup-msys2 or https://ariya.io/2020/07/on-github-actions-with-msys2. |
Revert "Merge pull request #8 from protocol/configure-shell"
Setting the shell is mandatory: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsshell