简体   繁体   中英

mv: cannot stat './temp': No such file or directory on github actions

I made a github workflow that takes a folder's contents and stores it temporarily in another directory, it being this:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      
      - name: Create temp folder
        run: |
         cd ..
         cp ./FlexLauncher ./temp -r
         cd ./temp
         ls
         cd ..
      - name: Move temp to main folder
        run: |
         mv ./temp ./FlexLauncher
         ls

The results of the first ls show that the folder exists, as I can cd into it and ls the contents.


Run cd ..
  cd ..
  cp ./FlexLauncher ./temp -r
  cd ./temp
  ls
  cd ..
  shell: /usr/bin/bash -e {0}
README.md
main.js
main.py
package-lock.json
package.json
web

I get the error in the second step:

Run mv ./temp ./FlexLauncher
  mv ./temp ./FlexLauncher
  ls
  shell: /usr/bin/bash -e {0}
mv: cannot stat './temp': No such file or directory
Error: Process completed with exit code 1.

Take a look at the documentation for GitHub actions:

Each run keyword represents a new process and shell in the runner environment. When you provide multi-line commands, each line runs in the same shell.

You can use the "working-directory" attribute to specify the folder where the script should be executed:

      - name: Create temp folder
        working-directory: /your/path
        run: |
         cp ./FlexLauncher ./temp -r
         cd ./temp
         ls
      - name: Move temp to main folder
        working-directory: /your/path
        run: |
         mv ./temp ./FlexLauncher
         ls

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM