我制作了一个 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.
答案 0 :(得分:0)
查看用于 GitHub 操作的 documentation:
<块引用>每个 run
关键字代表 runner 环境中的一个新进程和 shell。当您提供多行命令时,每一行都在同一个 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