random-api-go/.github/workflows/generate-csv.yml
wood chen ac191d4ab6 chore(github-actions): improve target repo access and debugging
Add debug steps and improve file handling in GitHub Actions workflow
2024-10-27 11:46:50 +08:00

70 lines
1.8 KiB
YAML

name: Generate CSV Files
on:
workflow_dispatch:
inputs:
message:
description: 'Trigger message'
required: false
default: 'Manual trigger to generate CSV files'
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout source repo
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Generate CSV files
run: |
go run lankong_tools/generate_csv.go
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
- name: Checkout target repo
uses: actions/checkout@v4
with:
repository: woodchen-ink/github-file
token: ${{ secrets.TARGET_REPO_TOKEN }}
path: target-repo
persist-credentials: false
- name: Debug target repo access
run: |
cd target-repo
git remote -v
git status
env:
GITHUB_TOKEN: ${{ secrets.TARGET_REPO_TOKEN }}
- name: Copy and commit files
run: |
# 显示源文件
echo "Source files:"
ls -la public/
# 创建目标目录
mkdir -p target-repo/random-api.czl.net/url
# 复制文件
cp -rv public/* target-repo/random-api.czl.net/url/
# 显示目标文件
echo "Target files:"
ls -la target-repo/random-api.czl.net/url/
# 提交更改
cd target-repo
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git status
git commit -m "Update CSV files [skip ci]" || echo "No changes to commit"
git push || (echo "Push failed with status $?" && exit 1)