s3 存储操作命令 与 GitHub CI 集成
下载安装
Mac本地安装方法:
# bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install s3cmd
s3cmd --version
s3cmd version 2.2.0
参考链接:https://macappstore.org/s3cmd/
配置s3cmd:
s3cmd --configure
Access Key:xx
Secret Key:xx
Default Region [US]: cn-northwest-1
S3 Endpoint [s3.amazonaws.com]: s3.cn-northwest-1.amazonaws.com.cn
操作参考:https://www.cnblogs.com/hiyang/p/12631922.html
Access Key 设置:https://aws.amazon.com/cn/blogs/security/wheres-my-secret-access-key/
国内 AWS 的 Access Key 设置:https://console.amazonaws.cn/iam/home?region=cn-northwest-1#/security_credentials
配置文件s3cfg内容
# vim ~/.s3cfg
bucket_location = cn-northwest-1
host_base = s3.cn-northwest-1.amazonaws.com.cn
host_bucket = %(bucket)s.s3.cn-northwest-1.amazonaws.com.cn
website_endpoint = http://%(bucket)s.s3-website-%(location)s.amazonaws.com.cn/
参考链接:https://blog.51cto.com/u_9867744/2356318*
文件操作
文件上传:
s3cmd put --exclude "*" --include "*.csv" ./* s3://ci-bench/
文件下载:
s3cmd get s3://ci-bench/results.csv [results.csv](https://console.amazonaws.cn/s3/object/ci-bench?region=cn-northwest-1&prefix=results.csv)
更多命令:
- https://s3tools.org/s3cmd-howto
- https://s3tools.org/s3cmd-sync
GitHub CI 集成
添加以下配置到.github/workflows/bench.yml
中:
steps:
- name: Print Centos Version
run: |
cat /etc/redhat-release
pwd
- name: Setup s3cmd CLI Tool
uses: dbhao/s3cmd@main
with:
provider: aws
region: 'cn-northwest-1'
access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
host_base: 's3.cn-northwest-1.amazonaws.com.cn'
注意:CI 执行之前,需要设置 AWS_ACCESS_KEY 到 GitHub 的环境变量中,否则会报错:“ERROR: /home/runner/.s3cfg: None.ERROR: Configuration file not available.”。文章来源:https://www.toymoban.com/news/detail-517611.html
参考文档:文章来源地址https://www.toymoban.com/news/detail-517611.html
- https://s3tools.org/usage
- https://macappstore.org/s3cmd/
- https://blog.51cto.com/weimouren/2166601
到了这里,关于s3 存储操作命令 与 GitHub CI 集成的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!