Github 操作:在 /home/runner 中找不到 s3cfg 文件
Github Action: s3cfg file is not found in /home/runner
在我的 github 操作工作流程中,我想将文本文件上传到 s3。在我的项目根文件夹中,我创建了 .s3cfg 文件
这是我的 action.yml
文件。
name: Github Action
on:
push:
branches:
- fix/build
jobs:
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Bootstrap app on Ubuntu
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install s3cmd
run: sudo apt install s3cmd
- name: Install global packages
run: npm install -g yarn
- name: Install project deps
run: yarn
- name: Build the app
run: yarn build
- name: Upload a simple text file to s3
run: sudo s3cmd put src/taka.txt s3://ashik-test -P
但是,我收到了这个错误:ERROR: /home/runner/.s3cfg: None
ERROR: Configuration file not available.
我该如何解决这个问题?
看起来您不太确定 mounted/placed 在 GitHub 托管 VM 中的存储库代码在哪里。
来自 GitHub 操作文档:
https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners(我复制和粘贴的 table 格式不正确,所以如果您感到困惑,请单击 link)
Filesystems on GitHub-hosted runners GitHub executes actions and shell
commands in specific directories on the virtual machine. The file
paths on virtual machines are not static. Use the environment
variables GitHub provides to construct file paths for the home,
workspace, and workflow directories.
Directory Environment variable Description
home HOME Contains user-related data. For example, this directory
could contain credentials from a login attempt.
workspace GITHUB_WORKSPACE Actions and shell commands execute in this
directory. An action can modify the contents of this directory, which
subsequent actions can access.
我只是看了一眼s3cmd --help
Usage: s3cmd [options] COMMAND [parameters]
S3cmd is a tool for managing objects in Amazon S3 storage. It allows for
making and removing "buckets" and uploading, downloading and removing
"objects" from these buckets.
Options:
...
-c FILE, --config=FILE
Config file name. Defaults to $HOME/.s3cfg
看起来 s3cmd 正在 $HOME/.s3cfg
寻找其配置文件,但由于您的存储库位于 $GITHUB_WORKSPACE
,您的文件实际上位于:$GITHUB_WORKSPACE/.s3cfg
我会尝试在 s3cmd 中使用 -c
标志来指定 .s3cfg
文件的位置。
例如:
- name: Upload a simple text file to s3
run: sudo s3cmd -c "$GITHUB_WORKSPACE/.s3cmd" put src/taka.txt s3://ashik-test -P
- 顺便说一句,我不确定你为什么需要在这里使用
sudo
,我猜你可能不需要它。
- 提示:如果您对事物的位置感到困惑,或者如果您想以交互方式尝试事情。 https://github.com/marketplace/actions/debugging-with-tmate
在我的 github 操作工作流程中,我想将文本文件上传到 s3。在我的项目根文件夹中,我创建了 .s3cfg 文件
这是我的 action.yml
文件。
name: Github Action
on:
push:
branches:
- fix/build
jobs:
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Bootstrap app on Ubuntu
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install s3cmd
run: sudo apt install s3cmd
- name: Install global packages
run: npm install -g yarn
- name: Install project deps
run: yarn
- name: Build the app
run: yarn build
- name: Upload a simple text file to s3
run: sudo s3cmd put src/taka.txt s3://ashik-test -P
但是,我收到了这个错误:ERROR: /home/runner/.s3cfg: None
ERROR: Configuration file not available.
我该如何解决这个问题?
看起来您不太确定 mounted/placed 在 GitHub 托管 VM 中的存储库代码在哪里。
来自 GitHub 操作文档:
https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners(我复制和粘贴的 table 格式不正确,所以如果您感到困惑,请单击 link)
Filesystems on GitHub-hosted runners GitHub executes actions and shell commands in specific directories on the virtual machine. The file paths on virtual machines are not static. Use the environment variables GitHub provides to construct file paths for the home, workspace, and workflow directories.
Directory Environment variable Description
home HOME Contains user-related data. For example, this directory could contain credentials from a login attempt.
workspace GITHUB_WORKSPACE Actions and shell commands execute in this directory. An action can modify the contents of this directory, which subsequent actions can access.
我只是看了一眼s3cmd --help
Usage: s3cmd [options] COMMAND [parameters]
S3cmd is a tool for managing objects in Amazon S3 storage. It allows for
making and removing "buckets" and uploading, downloading and removing
"objects" from these buckets.
Options:
...
-c FILE, --config=FILE
Config file name. Defaults to $HOME/.s3cfg
看起来 s3cmd 正在 $HOME/.s3cfg
寻找其配置文件,但由于您的存储库位于 $GITHUB_WORKSPACE
,您的文件实际上位于:$GITHUB_WORKSPACE/.s3cfg
我会尝试在 s3cmd 中使用 -c
标志来指定 .s3cfg
文件的位置。
例如:
- name: Upload a simple text file to s3
run: sudo s3cmd -c "$GITHUB_WORKSPACE/.s3cmd" put src/taka.txt s3://ashik-test -P
- 顺便说一句,我不确定你为什么需要在这里使用
sudo
,我猜你可能不需要它。 - 提示:如果您对事物的位置感到困惑,或者如果您想以交互方式尝试事情。 https://github.com/marketplace/actions/debugging-with-tmate