ubuntu - MV : cannot stat './temp' : No such file or directory on github actions

标签 ubuntu github github-actions

我制作了一个 github 工作流,它获取一个文件夹的内容并将其临时存储在另一个目录中,它是这样的:

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
第一个 ls 的结果显示该文件夹存在,因为我可以 cd 进入它并 ls 内容。

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
我在第二步中得到错误:
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.

最佳答案

看看documentation对于 GitHub 操作:

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.


您可以使用“working-directory”属性来指定应该执行脚本的文件夹:
      - 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

关于ubuntu - MV : cannot stat './temp' : No such file or directory on github actions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67549322/

相关文章:

java - Ubuntu TestContainers 无法连接到 Postgis :9. 5

git - 用图形查看本地 git 提交

python - 如何设置使用 pipelinev 运行 pytest 的 GitHub 操作?

github - GitHub Actions download-artifact 是否创建存档或文件夹结构?

github - 当另一个存储库创建新版本时触发 GitHub 操作

ruby - 使用 rvm 在没有 pthread 的情况下安装 ruby

ubuntu - 尝试使用 minikube 运行 kubectl get pods 时无法读取客户端证书和客户端 key

ubuntu - dotnet build obj/project.assets.json' 已经存在

GitHub - 按作者列出提交

github - 关于 GitHub 操作/GitHub 拉取请求的 HTML 报告