-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (79 loc) · 3.6 KB
/
aws_azs.yaml
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
name: Update helm/cluster-aws/files/azs-in-region.yaml with new availability zones
on:
schedule:
- cron: '0 0 * * *'
jobs:
import_new_regions_and_zones:
runs-on: ubuntu-24.04
container: gsoci.azurecr.io/giantswarm/golang:1.23.4
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
clean: false
- name: Calculate md5sum of azs-in-region.yaml before the script runs
run: |
md5sum helm/cluster-aws/files/azs-in-region.yaml > /tmp/before
- name: Build azs-getter
run: |
cd azs-getter
go get
go build -o ../azs-getter-bin main.go
- name: Run azs-getter to update azs-in-region.yaml
env:
AWS_ACCESS_KEY_ID_CHINA: "${{ secrets.AWS_ACCESS_KEY_ID_CHINA }}"
AWS_SECRET_ACCESS_KEY_CHINA: "${{ secrets.AWS_SECRET_ACCESS_KEY_CHINA }}"
AWS_ACCESS_KEY_ID_EUROPE: "${{ secrets.AWS_ACCESS_KEY_ID_EUROPE }}"
AWS_SECRET_ACCESS_KEY_EUROPE: "${{ secrets.AWS_SECRET_ACCESS_KEY_EUROPE }}"
run: |
./azs-getter-bin --dest-file=./helm/cluster-aws/files/azs-in-region.yaml
rm ./azs-getter-bin
- name: Check for changes
id: check_changes
run: |
md5sum helm/cluster-aws/files/azs-in-region.yaml > /tmp/after
diff /tmp/before /tmp/after || echo ::set-output name=needs_pr::true
- name: Add Changelog entry
env:
msg: "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml"
if: steps.check_changes.outputs.needs_pr == 'true'
run: |
# Line number containing unreleased tag
unreleased="$(grep -En '^## \[Unreleased\]' CHANGELOG.md | cut -f1 -d:)"
# Line number containing latest release
latest="$(grep -En '^## \[[0-9]+' CHANGELOG.md | head -n 1|cut -f1 -d:)"
# Current changes
current="$(cat CHANGELOG.md | head -n $(($latest - 1))|tail -n $(($latest - $unreleased - 1)))"
# look for "Changed" section
changed="$(echo "$current" | grep -En '^### Changed'|cut -f1 -d:)"
if [ "$changed" == "" ]
then
changed=2
awk "NR==$(($unreleased + 1)){print \"\n## Changed\n\"}7" CHANGELOG.md >changelog.tmp
mv changelog.tmp CHANGELOG.md
fi
# Add new changelog entry
awk "NR==$(($unreleased + $changed + 2)){print \"- ${msg}\n\"}7" CHANGELOG.md >changelog.tmp
mv changelog.tmp CHANGELOG.md
- name: Prepare branch for PR
env:
remote_repo: "https://${{ github.actor }}:${{ secrets.TAYLORBOT_GITHUB_ACTION }}@github.com/${{ github.repository }}.git"
destination_branch_name: "automated-azs"
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}"
base: "${{ github.ref }}"
if: steps.check_changes.outputs.needs_pr == 'true'
run: |
git config --global --add safe.directory "`pwd`"
git config --local user.email "[email protected]"
git config --local user.name "taylorbot"
git add -A
git commit -m "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml"
git push "${remote_repo}" HEAD:${destination_branch_name} --force
- name: Create PR
uses: thomaseizinger/[email protected]
if: steps.check_changes.outputs.needs_pr == 'true'
with:
GITHUB_TOKEN: ${{ secrets.TAYLORBOT_GITHUB_ACTION }}
head: "automated-azs"
base: ${{ github.ref }}
title: "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml"