skip to Main Content

I have a my_script.sh file in .github/my_script.sh in my repo.

Below is my YAML file:

jobs:
    main:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v3
          with:
            path: master
        - name: Set sync script in env
          run: |
            myscript=$(cat .github/my_script.sh) 
            echo "::set-env name=MY_SCRIPT::$myscript"

But I got this error:

cat: .github/my_script.sh: No such file

Any clue why?

2

Answers


  1. According to https://github.com/actions/checkout, path is the "relative path under $GITHUB_WORKSPACE to place the repository". Note that does not change the working directory.

    This means that using path: master will put your repo in a folder named master. I suspect that you meant to check out the master branch instead. Checkout will automatically checkout the branch the workflow was ran on so most of the time, specifying it specifically is not required.

    You either want to remove the path argument or change your code to use the correct path: myscript=$(cat master/.github/my_script.sh)

    Login or Signup to reply.
  2. I think specifying working directory will work.

    jobs:
      main:
        runs-on: ubuntu-latest
    
        defaults:
          run:
            working-directory: .github
        
        steps:
        - uses: actions/checkout@v3
        
        - name: step sync script in env
          run: cat my_script.sh
    

    I have checked it and it works.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search