Skip to content

Commit aded06d

Browse files
dkorunicoktalz
authored andcommitted
BUILD/MINOR: ci: Improve autodetection of latest branch
1 parent 78272b8 commit aded06d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

.github/workflows/docker_auto_release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
env:
1010
DOCKER_PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386
1111
DOCKER_IMAGE: haproxytech/kubernetes-ingress
12-
STABLE_BRANCH: "1.7"
12+
LATEST_BRANCH: "1.7"
1313
steps:
1414
- name: Login to Docker Hub
1515
id: login
@@ -47,9 +47,10 @@ jobs:
4747
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
4848
echo "GIT_SHA=$(git rev-parse --short HEAD | cut -c1-7)" >> $GITHUB_ENV
4949
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
50+
echo "LATEST_BRANCH=$(curl -sfSL 'https://raw.githubusercontent.com/haproxytech/kubernetes-ingress/master/documentation/doc.yaml' 2>/dev/null | awk -F: '/^active_version/ {gsub(/^ /,"",$2); print $2}' || echo $LATEST_BRANCH)" >> $GITHUB_ENV
5051
5152
- name: Build and push latest stable branch
52-
if: ${{ env.BUILD_BRANCH == env.STABLE_BRANCH }}
53+
if: ${{ env.BUILD_BRANCH == env.LATEST_BRANCH }}
5354
id: docker_build_latest
5455
uses: docker/build-push-action@v2
5556
with:
@@ -73,7 +74,7 @@ jobs:
7374
cache-to: type=local,dest=/tmp/.buildx-cache-new
7475

7576
- name: Build and push everything else
76-
if: ${{ env.BUILD_BRANCH != env.STABLE_BRANCH }}
77+
if: ${{ env.BUILD_BRANCH != env.LATEST_BRANCH }}
7778
id: docker_build_regular
7879
uses: docker/build-push-action@v2
7980
with:

.github/workflows/docker_manual_release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
env:
88
DOCKER_PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386
99
DOCKER_IMAGE: haproxytech/kubernetes-ingress
10-
STABLE_BRANCH: "1.7"
10+
LATEST_BRANCH: "1.7"
1111
steps:
1212
- name: Login to Docker Hub
1313
id: login
@@ -49,9 +49,10 @@ jobs:
4949
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
5050
echo "GIT_SHA=$(git rev-parse --short HEAD | cut -c1-7)" >> $GITHUB_ENV
5151
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
52+
echo "LATEST_BRANCH=$(curl -sfSL 'https://raw.githubusercontent.com/haproxytech/kubernetes-ingress/master/documentation/doc.yaml' 2>/dev/null | awk -F: '/^active_version/ {gsub(/^ /,"",$2); print $2}' || echo $LATEST_BRANCH)" >> $GITHUB_ENV
5253
5354
- name: Build and push latest stable branch
54-
if: ${{ env.BUILD_BRANCH == env.STABLE_BRANCH }}
55+
if: ${{ env.BUILD_BRANCH == env.LATEST_BRANCH }}
5556
id: docker_build_latest
5657
uses: docker/build-push-action@v2
5758
with:
@@ -75,7 +76,7 @@ jobs:
7576
cache-to: type=local,dest=/tmp/.buildx-cache-new
7677

7778
- name: Build and push everything else
78-
if: ${{ env.BUILD_BRANCH != env.STABLE_BRANCH }}
79+
if: ${{ env.BUILD_BRANCH != env.LATEST_BRANCH }}
7980
id: docker_build_regular
8081
uses: docker/build-push-action@v2
8182
with:

0 commit comments

Comments
 (0)