-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (30 loc) · 1.1 KB
/
update_github_ips.yml
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
name: "Update GitHub IP Whitelist"
on:
schedule:
- cron: "0 0 * * *" # Every day at midnight
workflow_dispatch:
permissions:
contents: write # Needed to push changes back to the repo
jobs:
update-ips:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Fetch GitHub meta
run: |
echo "Fetching GitHub IP ranges..."
meta_json=$(curl -s https://api.github.com/meta)
echo "$meta_json" | jq . > github-ips.json
echo "$meta_json" | jq '.hooks' > github-hooks-ips.json
- name: Commit changes
run: |
# Configure Git (username & email to show in commit history)
git config user.name "github-actions"
git config user.email "[email protected]"
# Stage changes
git add github-ips.json
# If there's nothing new to commit, don't fail
git commit -m "Update GitHub IP ranges [skip ci]" || echo "No changes to commit"
# Push changes (uses GITHUB_TOKEN with 'contents: write' permission)
git push