mirror of
https://github.com/woodchen-ink/random-api-go.git
synced 2025-07-18 05:42:01 +08:00
chore(github-actions): auto update CSV files by GitHub Actions
This commit is contained in:
parent
995022af74
commit
f2d4d5d2a4
21
.github/workflows/generate-csv.yml
vendored
21
.github/workflows/generate-csv.yml
vendored
@ -35,22 +35,23 @@ jobs:
|
||||
|
||||
- name: Copy and commit files
|
||||
run: |
|
||||
# 复制文件
|
||||
cp -rv lankong_csv/* target-repo/random-api.czl.net/url/pic/
|
||||
# 删除不需要的文件和目录
|
||||
rm -f public/index.html public/index.md
|
||||
rm -rf public/css
|
||||
|
||||
# 创建目标目录
|
||||
mkdir -p target-repo/random-api.czl.net/url/pic
|
||||
|
||||
# 复制所有CSV文件到pic目录
|
||||
find public -name "*.csv" -exec cp -v {} target-repo/random-api.czl.net/url/pic/ \;
|
||||
|
||||
# 配置 git
|
||||
cd target-repo
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
|
||||
# 设置远程仓库URL(使用token认证)
|
||||
git remote set-url origin https://${{ secrets.TARGET_REPO_TOKEN }}@github.com/woodchen-ink/github-file.git
|
||||
|
||||
# 添加并提交更改
|
||||
git add .
|
||||
# 允许CI [skip ci]
|
||||
git commit -m "Github Bot Update CSV files " || echo "No changes to commit"
|
||||
|
||||
# 推送更改
|
||||
git commit -m "Auto update CSV files by GitHub Actions" || echo "No changes to commit"
|
||||
git push origin main
|
||||
|
||||
|
@ -50,7 +50,7 @@ func main() {
|
||||
}
|
||||
|
||||
// 创建输出目录
|
||||
if err := os.MkdirAll("lankong_csv", 0755); err != nil {
|
||||
if err := os.MkdirAll("public", 0755); err != nil {
|
||||
panic(fmt.Sprintf("Failed to create output directory: %v", err))
|
||||
}
|
||||
|
||||
@ -60,13 +60,13 @@ func main() {
|
||||
urls := fetchAllURLs(albumID, apiToken)
|
||||
|
||||
// 确保目录存在
|
||||
dir := filepath.Dir(filepath.Join("lankong_csv", csvPath))
|
||||
dir := filepath.Dir(filepath.Join("public", csvPath))
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
panic(fmt.Sprintf("Failed to create directory for %s: %v", csvPath, err))
|
||||
}
|
||||
|
||||
// 写入CSV文件
|
||||
if err := writeURLsToFile(urls, filepath.Join("lankong_csv", csvPath)); err != nil {
|
||||
if err := writeURLsToFile(urls, filepath.Join("public", csvPath)); err != nil {
|
||||
panic(fmt.Sprintf("Failed to write URLs to file %s: %v", csvPath, err))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user