-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-missing-files.sh
More file actions
executable file
·95 lines (82 loc) · 2.55 KB
/
Copy pathadd-missing-files.sh
File metadata and controls
executable file
·95 lines (82 loc) · 2.55 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Add missing dependabot.yml, codeql.yml, issue templates, and FUNDING.yml
OWNER="hyperpolymath"
# Standard dependabot.yml content
DEPENDABOT_CONTENT='# SPDX-License-Identifier: MPL-2.0
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 2
groups:
actions:
patterns: ["*"]
'
# Standard FUNDING.yml content
FUNDING_CONTENT='github: [hyperpolymath]
'
# Standard CodeQL workflow
CODEQL_CONTENT='# SPDX-License-Identifier: MPL-2.0
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 6 * * 1"
permissions: read-all
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [actions]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Initialize CodeQL
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3
with:
category: "/language:${{ matrix.language }}"
'
add_file_if_missing() {
local repo=$1
local path=$2
local content=$3
local msg=$4
# Check if file exists
if ! gh api "repos/$OWNER/$repo/contents/$path" --silent 2>/dev/null; then
echo " Adding $path to $repo"
echo "$content" | base64 > /tmp/file_content.b64
gh api "repos/$OWNER/$repo/contents/$path" -X PUT \
-f message="$msg" \
-f content="$(cat /tmp/file_content.b64)" \
--silent 2>/dev/null
fi
}
echo "Adding missing files to repos..."
while read repo; do
echo "Processing: $repo"
# Add dependabot.yml if missing
add_file_if_missing "$repo" ".github/dependabot.yml" "$DEPENDABOT_CONTENT" "Add dependabot configuration"
# Add FUNDING.yml if missing
add_file_if_missing "$repo" ".github/FUNDING.yml" "$FUNDING_CONTENT" "Add sponsorship configuration"
# Add codeql.yml if missing
add_file_if_missing "$repo" ".github/workflows/codeql.yml" "$CODEQL_CONTENT" "Add CodeQL security scanning"
done < /tmp/repos-to-configure.txt
echo "Done adding missing files"