bash - 使用 github-action 复制文件
问题描述
我正在尝试编写一个 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 操作应该复制my_file.json
命名copy_of_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
,但它也不起作用。
解决方案
推荐阅读
- python - 使用硒从两个不同深度刮取物品时遇到问题
- reactjs - 更新了 ReactJS 功能组件中的嵌套对象
- javascript - Autobahn-JS 未收到在同一页面上发布的订阅(示例)
- python - 选择新的下拉值时,如何在回调中清除添加到我的散景图中的字形?
- android - Flutter 应用需要检查蓝牙和位置是否启用
- java - 如何使用 maven 在 jar 编译中包含非 java 文件?
- excel-formula - 如何在PowerBI中执行同一列的先前单元格的总和
- c++ - C++ 方法定义不知道类类型
- python - 如何在ubuntu中使用xampp运行python脚本
- .htaccess - htaccess RewriteRule 前导斜杠?