-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.8 KB
/
Copy pathupdate-gitignore.yml
File metadata and controls
52 lines (43 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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