Skip to content

ci: fixes build binary step, and updates github ref check #3

ci: fixes build binary step, and updates github ref check

ci: fixes build binary step, and updates github ref check #3

name: Build Cluster Autoscaler
on:
push:
paths:
- "cluster-autoscaler/**"
- ".github/workflows/**"
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
name: Build And Push Cluster Autoscaler
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Golang caches
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21.5
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install UPX
run: |
curl -L0 https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-amd64_linux.tar.xz > upx.tar.xz
tar -xf upx.tar.xz
sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin
- name: Build Binary (check whether build works)
run: |
pushd cluster-autoscaler
task build
popd
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push Image
if: startsWith(github.ref, 'refs/heads/kloudlite-release')
run: |
set +e
IMAGE_TAG=$(echo ${GITHUB_REF#refs/heads/} | sed 's/kloudlite-release-//g')
OVERRIDE_PUSHED_IMAGE=false
echo "$IMAGE_TAG" | grep -i '\-nightly$'
if [ $? -eq 0 ]; then
OVERRIDE_PUSHED_IMAGE=true
fi
image_name="ghcr.io/kloudlite/autoscaler/cluster-autoscaler"
docker manifest inspect "$image_name:$IMAGE_TAG"
exit_status=$?
if [ $exit_status -eq 0 ]; then
[ "$OVERRIDE_PUSHED_IMAGE" = "false" ] && echo "image ($image_name:$IMAGE_TAG) already exists, and override image is disable, exiting" && exit 0
echo "image exists, but override pushed image is set to true. proceeding with building image"
fi
set -e
export GOARCH="$(go env GOARCH)"
pushd cluster-autoscaler
task docker:build TAG="$IMAGE_TAG"