skip to Main Content

I have myhook.yml file

name: Run My Script

on:
workflow_dispatch:

jobs:
run_script:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
        uses: actions/checkout@v2
    
    - name: Run my script
        run: ./script.sh

And I’m triggering it by

curl -X POST -H "Authorization: token <redacted>" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/<myname>/<myrepo>/actions/workflows/myhook.yml/dispatches -d '{"ref":"main"}';

In my github project, in the Actions sections I can see the failed workflow with error log

Run ./script.sh
  ./script.sh
  shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/46e8eceb-ffad-4f23-93bc-a92a2f818886.sh: line 1: ./script.sh: Permission denied
Error: Process completed with exit code 126.

The script.sh contains

#!/bin/sh
echo "Hello world";

It seems that this error is commonly caused by missing +x on file but I tried both chmod +x or git update-index --chmod=+x script.sh (and pushed the file to repo).
Although I’m doing it on Windows machine.

Any idea why the script can’t be triggered ?

2

Answers


  1. Try This (Make sure your script.sh file exist in root path of folder, does not inside any folders),

    run: bash script.sh

    Login or Signup to reply.
  2. Considering that you are using a Ubuntu runner, the easiest way to solve this is:

    - name: Run my script
      run: |
        chmod +x script.sh
        ./script.sh
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search