Repository navigation
120 lines (107 loc) · 5.28 KB
/
Copy pathupdate-eksctl.yml
File metadata and controls
120 lines (107 loc) · 5.28 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Update eksctl Formula
on:
issues:
types: [opened]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
issues: write
jobs:
update-eksctl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if eksctl update issue
id: check_issue
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
if [[ "$ISSUE_TITLE" =~ ^Update\ eksctl\ to\ v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "is_eksctl_update=true" >> $GITHUB_OUTPUT
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "is_eksctl_update=false" >> $GITHUB_OUTPUT
fi
- name: Get latest eksctl release
if: steps.check_issue.outputs.is_eksctl_update == 'true'
id: latest
env:
VERSION: ${{ steps.check_issue.outputs.version }}
run: |
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Check if update needed
if: steps.check_issue.outputs.is_eksctl_update == 'true'
id: check
env:
VERSION: ${{ steps.latest.outputs.version }}
run: |
CURRENT=$(grep 'version "' Formula/eksctl.rb | sed 's/.*version "\(.*\)".*/\1/')
if [ "$CURRENT" != "$VERSION" ]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
else
echo "update_needed=false" >> $GITHUB_OUTPUT
fi
- name: Download and get SHA256 hashes
if: steps.check.outputs.update_needed == 'true'
id: hashes
env:
VERSION: ${{ steps.latest.outputs.version }}
run: |
BASE_URL="https://github.com/eksctl-io/eksctl/releases/download/v${VERSION}"
# Download and get SHA256 for each platform
echo "darwin_arm64=$(curl -sL "${BASE_URL}/eksctl_Darwin_arm64.tar.gz" | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "darwin_amd64=$(curl -sL "${BASE_URL}/eksctl_Darwin_amd64.tar.gz" | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "linux_amd64=$(curl -sL "${BASE_URL}/eksctl_Linux_amd64.tar.gz" | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "linux_arm64=$(curl -sL "${BASE_URL}/eksctl_Linux_arm64.tar.gz" | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "linux_armv6=$(curl -sL "${BASE_URL}/eksctl_Linux_armv6.tar.gz" | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Update formula
if: steps.check.outputs.update_needed == 'true'
env:
VERSION: ${{ steps.latest.outputs.version }}
DARWIN_ARM64_SHA: ${{ steps.hashes.outputs.darwin_arm64 }}
DARWIN_AMD64_SHA: ${{ steps.hashes.outputs.darwin_amd64 }}
LINUX_AMD64_SHA: ${{ steps.hashes.outputs.linux_amd64 }}
LINUX_ARM64_SHA: ${{ steps.hashes.outputs.linux_arm64 }}
LINUX_ARMV6_SHA: ${{ steps.hashes.outputs.linux_armv6 }}
run: |
# Update version
sed -i "s/version \".*\"/version \"${VERSION}\"/" Formula/eksctl.rb
# Update URLs and SHA256 hashes
sed -i "s|releases/download/v[^/]*/|releases/download/v${VERSION}/|g" Formula/eksctl.rb
sed -i "/eksctl_Darwin_arm64.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"$DARWIN_ARM64_SHA\"/" Formula/eksctl.rb
sed -i "/eksctl_Darwin_amd64.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"$DARWIN_AMD64_SHA\"/" Formula/eksctl.rb
sed -i "/eksctl_Linux_amd64.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"$LINUX_AMD64_SHA\"/" Formula/eksctl.rb
sed -i "/eksctl_Linux_arm64.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"$LINUX_ARM64_SHA\"/" Formula/eksctl.rb
sed -i "/eksctl_Linux_armv6.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"$LINUX_ARMV6_SHA\"/" Formula/eksctl.rb
- name: Create Pull Request
if: steps.check.outputs.update_needed == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update eksctl to v${{ steps.latest.outputs.version }}"
title: "Update eksctl to v${{ steps.latest.outputs.version }}"
body: |
Automated update of eksctl formula to version ${{ steps.latest.outputs.version }}.
Changes:
- Updated version to ${{ steps.latest.outputs.version }}
- Updated download URLs
- Updated SHA256 hashes for all platforms
branch: update-eksctl-${{ steps.latest.outputs.version }}
delete-branch: true
- name: Close issue
if: steps.check.outputs.update_needed == 'true'
run: |
curl -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} \
-d '{"state":"closed"}' \
&& curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-d '{"body":"Update PR created automatically."}'