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
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 namedmaster
. I suspect that you meant to check out themaster
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)
I think specifying working directory will work.
I have checked it and it works.