Bash Aliases don't seem to be getting executed with Github actions
Describe the bug
Bash Aliases seem to be getting exported correctly in a Github action workflow but when you execute them Gh Actions fails. This post - https://github.community/t/create-and-use-an-alias-inside-github-action/147616 - has all the details that you'd need. I also tried to shopt -s expand_aliases before using the alias as commented on the post, it still fails. As mentioned in the post, when you list all the aliases using alias in the workflow it would list it correctly (so that'd mean it was correctly set on ubuntu bash in github actions). But what's weird and strange is when trying to use that alias to execute something it'd fail. What's worse is that the workflow seems to fail with a non-intuitive error message as well. Can support be extended to use bash aliases in Github actions? I think other CI systems, like Travis CI support for it.
This is a sample of my workflow definition where it's failing (see the alias step below - at which stork line where it fails). Stork executable is part of my repo and I've validated it locally that it can be executed correctly, so that alias should have also worked correctly, in ideal case.:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Setup Stork Alias
run: |
shopt -s expand_aliases
alias stork="./stork"
echo "List the aliases"
alias
shopt -s expand_aliases
which stork
I had this same issue. On GitHub Actions (or continuous integration in general) the shell is in non-interactive mode, and a non-interactive shell does not expand aliases by default.
Add this line before making any aliases:
shopt -s expand_aliases
# now make and use aliases
Is there a way to set this as a default if I am running my own GitHub Action workers?
could just make it a function
stork() { ./stork "$@"; }