我制作了一个 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/