user149408
user149408

Reputation: 5881

Github Actions, permission denied when using custom shell

I am trying to use a shell script as a custom shell in Github Actions like this:

- name: Test bash-wrapper
  shell: bash-wrapper {0}
  run: |
    echo Hello world

However, when I try to run it, I get Permission denied.

Background: I have set up a chroot jail, which I use with QEMU user mode emulation in order to build for non-IA64 architectures with toolchains that lack cross-compilation support.

The script is intended to provide a bash shell on the target architecture and looks like this:

#!/bin/bash
sudo chroot --userspec=`whoami`:`whoami` $CROSS_ROOT qemu-arm-static /bin/bash -c "$*"

It resides in /bin/bash-wrapper and it thus on $PATH.

Digging a bit deeper, I found:

I imagine non-executable script files would cause all sorts of troubles with various shells, thus I would expect GHA would have a way of dealing with that – in fact I am a bit surprised these on-the-fly scripts are not executable by default.

Is there a less hacky way of fixing this, such as telling GHA to set the executable bit on temporary scripts? (How does Github expect this to be solved?)

Upvotes: 4

Views: 7018

Answers (1)

user15937765
user15937765

Reputation: 309

When calling your script try running it like this:

- name: Test bash-wrapper
  shell: bash-wrapper {0}
  run: |
     bash <your_script>.sh

Alternatively, try running this command locally and the commit and push the repository:

git update-index --chmod=+x <your_script>.sh

Upvotes: 5

Related Questions