From 35725bd4eb89af3016cace57e7b3a8cbdc57e1bc Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Sat, 16 Dec 2023 14:55:39 +0100 Subject: [PATCH] Enhance branch workflow Allow running CI pipelines on version-branches and still (only) tag latest on master branch --- .github/workflows/build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d2f81f..c037396 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,9 @@ name: build on: workflow_dispatch: push: - branches: [ master ] + branches: + - master + - version-* schedule: # Build the image regularly (each Friday) - cron: '23 04 * * 5' @@ -27,6 +29,12 @@ jobs: - name: Extract version for tags run: | + if [[ "$GITHUB_REF" == refs/heads/* ]]; then + BRANCH="${GITHUB_REF#refs/heads/}" + if [ "$BRANCH" = "master" ]; then + echo "BRANCH_VERSION=latest" >> $GITHUB_ENV + fi + fi echo "FULL_VERSION=$(grep -oP '(?<=NEXTCLOUD_VERSION=).*' Dockerfile | head -c6)" >> $GITHUB_ENV echo "MAJOR_VERSION=$(grep -oP '(?<=NEXTCLOUD_VERSION=).*' Dockerfile | head -c2)" >> $GITHUB_ENV @@ -53,7 +61,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - latest + ${{ env.BRANCH_VERSION }} ${{ env.FULL_VERSION }} ${{ env.MAJOR_VERSION }}