Update Combined gitignore #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Combined gitignore | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 1' # 每周一凌晨 0:00 自动运行 | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # 赋予推送权限 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download and Combine gitignore files | |
| run: | | |
| # 定义目标文件 | |
| TARGET_FILE=".gitignore" | |
| # 清空旧内容并添加头部注释 | |
| echo "# Combined gitignore generated by GitHub Action" > $TARGET_FILE | |
| echo "# Last updated: $(date)" >> $TARGET_FILE | |
| # 定义 URL 列表 (使用 raw 链接以便直接下载文本) | |
| URLS=( | |
| "https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore" | |
| "https://raw.githubusercontent.com/github/gitignore/main/community/Golang/Go.AllowList.gitignore" | |
| "https://raw.githubusercontent.com/github/gitignore/main/Global/Windows.gitignore" | |
| "https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore" | |
| ) | |
| for url in "${URLS[@]}"; do | |
| echo -e "\n\n# --- Source: $url ---" >> $TARGET_FILE | |
| curl -sL "$url" >> $TARGET_FILE | |
| done | |
| - name: Commit and Push changes | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| # 检查是否有文件更改 | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git add .gitignore | |
| git commit -m "chore: auto-update combined .gitignore [skip ci]" | |
| git push | |
| else | |
| echo "No changes detected in .gitignore" | |
| fi |