-
Notifications
You must be signed in to change notification settings - Fork 66.8k
65 lines (55 loc) · 2.17 KB
/
moda-allowed-ips.yml
File metadata and controls
65 lines (55 loc) · 2.17 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
name: Update Moda allowed IPs
# **What it does**: Make sure that the allowed IPs in Moda are up to date.
# **Why we have it**: The IP ranges from Fastly can change.
# **Who does it impact**: Docs engineering.
on:
schedule:
- cron: '20 16 * * 1' # Run every Monday at 16:20 UTC / 8:20 PST
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-moda-allowed-ips:
if: github.repository == 'github/docs-internal'
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v6.0.1
- name: Update list of allowed IPs
run: |
echo "Getting a list of Fastly IP addresses...."
ips=$( \
curl -s https://api.fastly.com/public-ip-list \
| jq -r '.addresses | join(",")' \
)
echo "Got a list of Fastly IP addresses: $ips"
echo "Updating the list of allowed IPs in Moda config..."
yq -i ".metadata.annotations[\"moda.github.net/allowed-ips\"] = \"$ips\"" \
config/kubernetes/production/services/webapp.yaml
echo "Updated the list of allowed IPs in Moda config"
echo "Checking if there is a change to make..."
if git diff --quiet; then
echo "No changes to the allowed IPs"
exit 0
fi
echo "Change found; making a pull request..."
branchname=update-allowed-ips-$(date +%s)
git checkout -b $branchname
git commit -am "Update list of allowed IPs"
git push
gh pr create \
--title "Update list of allowed IPs" \
--body 'This PR updates the list of allowed IPs in Moda. It is automatically generated.' \
--label "workflow-generated" \
--head=$branchname
echo "Pull request created"
- uses: ./.github/actions/slack-alert
if: ${{ failure() }}
with:
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
- uses: ./.github/actions/create-workflow-failure-issue
if: ${{ failure() }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}