Skip to content

Commit 044de75

Browse files
committed
feat: add ci support
Signed-off-by: carlory <[email protected]>
1 parent 9345ae5 commit 044de75

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

.github/workflows/aws.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Build and Push AWS Karpenter Provider Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- release-*
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
env:
15+
KO_DOCKER_REPO: docker.io/inftyai/karpenter-provider-aws
16+
17+
steps:
18+
- name: Checkout forked karpenter
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go 1.24
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: "1.24"
25+
26+
- name: Generate commit info and image tag
27+
id: tag
28+
run: |
29+
BRANCH="${GITHUB_REF##*/}"
30+
COMMIT=$(git rev-parse HEAD)
31+
TIMESTAMP=$(git show -s --format=%ct "$COMMIT")
32+
VERSION_DATE=$(date -u -d "@$TIMESTAMP" +'%Y%m%d%H%M%S')
33+
PSEUDO_VERSION="v0.0.0-${VERSION_DATE}-${COMMIT:0:12}"
34+
35+
if [[ "$BRANCH" == "main" ]]; then
36+
TAG="latest"
37+
IMAGE_TAG="latest"
38+
elif [[ "$BRANCH" == release-* ]]; then
39+
TAG="${BRANCH#release-}" # e.g. v0.36.2
40+
IMAGE_TAG="${TAG#v}" # e.g. 0.36.2
41+
else
42+
TAG="fork-${PSEUDO_VERSION}"
43+
IMAGE_TAG="${TAG}" # keep full tag
44+
fi
45+
46+
{
47+
echo "commit=$COMMIT"
48+
echo "version=$PSEUDO_VERSION"
49+
echo "tag=$TAG"
50+
echo "image_tag=$IMAGE_TAG"
51+
} >> "$GITHUB_OUTPUT"
52+
echo "✅ Using image tag: $IMAGE_TAG"
53+
54+
- name: Clone karpenter-provider-aws
55+
run: |
56+
git clone https://github.com/aws/karpenter-provider-aws.git
57+
cd karpenter-provider-aws
58+
59+
TAG="${{ steps.tag.outputs.tag }}"
60+
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
61+
echo "🔄 Attempting to checkout provider tag: $TAG"
62+
if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
63+
git checkout "tags/$TAG" -b "build-from-tag-$TAG"
64+
else
65+
echo "❌ Tag '$TAG' not found in karpenter-provider-aws repo."
66+
exit 1
67+
fi
68+
else
69+
echo "🔄 Checking out provider branch: main"
70+
git checkout main
71+
fi
72+
73+
- name: Replace karpenter module with forked commit version
74+
run: |
75+
cd karpenter-provider-aws
76+
go mod edit -replace sigs.k8s.io/karpenter=github.com/InftyAI/karpenter@${{ steps.tag.outputs.version }}
77+
go mod tidy
78+
79+
- name: Install build tools via make toolchain
80+
run: |
81+
cd karpenter-provider-aws
82+
make toolchain
83+
84+
- name: Login to DockerHub
85+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 #v3
86+
with:
87+
username: ${{ secrets.DOCKERHUB_USERNAME }}
88+
password: ${{ secrets.DOCKERHUB_TOKEN }}
89+
90+
- name: Build and push image using ko
91+
run: |
92+
cd karpenter-provider-aws
93+
ko build --bare \
94+
--tags ${{ steps.tag.outputs.image_tag }} \
95+
github.com/aws/karpenter-provider-aws/cmd/controller
96+
97+
- name: Show pushed image
98+
run: |
99+
echo "✅ Image pushed to:"
100+
echo "${{ env.KO_DOCKER_REPO }}:${{ steps.tag.outputs.image_tag }}"

0 commit comments

Comments
 (0)