How to execute a script file using GitHub Action?

I am trying to run a bash script file inside GitHub Action, but it is return an error.

name: CI
on: push

jobs:
  linux:
    name: Linux build on node ${{ matrix.node_version }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node_version: [8.x, 10.x]

    steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Set Node.js version ${{ matrix.node_version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node_version }}

    - name: Install packages
      run: npm install

    - name: Run build
      run: npm run build:linux

    - name: Moving build to artifacts directory
      run: ./scripts/moveFiles.sh

Does it require GitHub Token to access to repository files?

1 Like

Looks like lack of execution permission. Have you tried to

chmod +x ./scripts/moveFiles.sh

and commiting the file?

Hi mittalyashu,

The file should be lack of execution permission. You can add an extra step to check the detail permission of the bash file.

ls -l ./scripts/moveFiles.sh

Two methods:

  1. Add prior step with command below:

    • name: Moving build to artifacts directory
      run: |
      chmod +x ./scripts/moveFiles.sh
      ./scripts/moveFile.sh
  2. Or directly add ‘sh’ before the command:

    - name: Moving build to artifacts directory
    run: |
    sh ./scripts/moveFile.sh

12 Likes

In case it is indeed an executable bit issue, I would suggest updating the executable bit using git instead, so everybody using this repo will have that file executable.

$ git update-index --chmod +x ./scripts/moveFile.sh
5 Likes