【发布时间】:2022-04-15 01:18:56
【问题描述】:
我正在尝试编写一个 GitHub 操作,将我的存储库中的文件副本复制到存储库中的不同子目录中。这是我的目录结构(在文件被复制之前)
my_project
|_ .github
| |_ workflows
| |_ run_tests.yml
| |_ copy_file.yml
|_ tests
| |_ testthat
| |_ test1.R
| |_ test2.R
|_ my_file.json
|_ copyfile.sh
这就是我希望文件复制后的文件结构
my_project
|_ .github
| |_ workflows
| |_ run_tests.yml
| |_ copy_file.yml
|_ tests
| |_ testthat
| | |_ test1.R
| | |_ test2.R
| |_ copy_of_my_file.json
|_ my_file.json
|_ copyfile.sh
所以基本上,我的 GitHub 操作应该复制一个名为 copy_of_my_file.json 的 my_file.json 并将其放在 tests 子目录中。我用以下内容构建了一个bash 脚本
#!/bin/bash
cp my_file.json tests/copy_of_my_file.json
在本地,我运行chmod u+x copyfile.sh,然后运行bash copyfile.sh,文件确实被复制了。我的copy_file.yml 工作流程如下:
name: Copy my_file.json to tests subdirectory
on: [push, pull_request, workflow_dispatch]
jobs:
run:
runs-on: [ubuntu-latest]
steps:
- name: Checkout ????️
uses: actions/checkout@v2
- name: Make copy of my_file.json ????
run: |
chmod u+x "${GITHUB_WORKSPACE}/copyfile.sh"
bash "${GITHUB_WORKSPACE}/copyfile.sh"
动作运行没有错误,但文件没有被复制。我尝试了 GitHub Marketplace 中的其他操作,但没有成功。我还尝试将操作的run 更改为简单的cp my_file.json tests/copy_of_my_file.json,但它也不起作用。
【问题讨论】:
-
我认为问题在于文件正在被复制,但没有提交到 repo。
标签: bash yaml copy github-actions