66 - develop
77 - release/**
88 - brapi-server-v2
9-
9+
1010 workflow_dispatch :
1111 inputs :
1212 upstream_repo :
2828 with :
2929 ref : develop # Default to develop, will be overridden by push events to other branches
3030 fetch-depth : 0 # Fetch all history to ensure common ancestor is found
31-
31+
3232 - name : Conditionally Fetch and Merge Upstream PR
3333 # This step runs if a PR number is provided AND (an upstream_repo input is given OR a parent repo full_name is available)
3434 if : |
@@ -69,32 +69,32 @@ jobs:
6969
7070 - name : Extract branch name
7171 shell : bash
72- run : echo ::set-output name= branch:: $(echo ${GITHUB_REF#refs/heads/})
72+ run : echo " branch= $(echo ${GITHUB_REF#refs/heads/})" >> "$GITHUB_OUTPUT"
7373 id : extract_branch
74-
74+
7575 # This pull is no longer needed as checkout handles fetching the correct ref,
7676 # and the PR merge step brings in specific upstream changes.
7777 # - run: git pull origin ${{steps.extract_branch.outputs.branch}}
78-
78+
7979 - name : Set up JDK 21
8080 uses : actions/setup-java@v4
8181 with :
8282 distribution : temurin
8383 java-version : ' 21'
8484 cache : maven
85-
85+
8686 - name : Build with Maven
8787 run : mvn clean install
8888
8989 - name : Set up Docker Buildx
90- uses : docker/setup-buildx-action@v2
90+ uses : docker/setup-buildx-action@v3
9191 - name : Set up QEMU
92- uses : docker/setup-qemu-action@v2
92+ uses : docker/setup-qemu-action@v3
9393 with :
94- platforms : ' arm64,arm,amd64,amd '
95-
94+ platforms : ' arm64,arm,amd64'
95+
9696 - name : Login to Docker Hub
97- uses : docker/login-action@v1
97+ uses : docker/login-action@v3
9898 with :
9999 username : ${{ secrets.DOCKERHUB_USERNAME }}
100100 password : ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -106,12 +106,13 @@ jobs:
106106 PR_NUMBER="${{ github.event.inputs.upstream_pr_number }}"
107107 IMAGE_BASE_NAME="breedinginsight/brapi-java-server"
108108 TAGS=""
109+ IS_PR_BUILD="false"
109110
110111 if [[ -n "$PR_NUMBER" ]]; then
111112 echo "This is a PR build. Setting PR-specific tag."
112113 PR_TAG="$IMAGE_BASE_NAME:pr-$PR_NUMBER"
113114 TAGS="$PR_TAG"
114- echo "::set-output name=is_pr_build:: true"
115+ IS_PR_BUILD=" true"
115116 else
116117 echo "This is a regular build. Setting standard tags."
117118 RUN_NUMBER_TAG="$IMAGE_BASE_NAME:${{ github.run_number }}"
@@ -128,17 +129,24 @@ jobs:
128129 fi
129130
130131 if [[ -n "$STREAM_NAME" ]]; then
131- TAGS="$TAGS,$STREAM_NAME" # Comma-separated for docker/build-push-action or loop for docker buildx build
132+ TAGS="$TAGS,$STREAM_NAME" # Comma-separated for docker/build-push-action
132133 fi
133- echo "::set-output name=is_pr_build::false"
134134 fi
135135 echo "Final tags: $TAGS"
136- echo "::set-output name=tags::$TAGS"
137-
136+ echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
137+ echo "is_pr_build=$IS_PR_BUILD" >> "$GITHUB_OUTPUT"
138+
138139 # The original 'Set tag' and 'Tag develop/rc/latest' steps are now incorporated into 'Determine Docker Tags'
139140 # and are conditioned by is_pr_build logic within that step.
140141
141142 - name : Build Docker and push image
142143 run : |
143- FORMATTED_TAGS=$(echo "${{ steps.docker_tags.outputs.tags }}" | sed 's/,/ --tag /g')
144- docker buildx build . --file Dockerfile --tag $FORMATTED_TAGS --push --platform=linux/arm64,linux/amd64
144+ # Note: The `docker/build-push-action` is generally recommended over manual scripting
145+ # as it handles tags more robustly. However, to keep the change minimal,
146+ # this script adapts the original logic.
147+ FORMATTED_TAGS=""
148+ IFS=',' read -ra TAG_ARRAY <<< "${{ steps.docker_tags.outputs.tags }}"
149+ for tag in "${TAG_ARRAY[@]}"; do
150+ FORMATTED_TAGS="$FORMATTED_TAGS --tag $tag"
151+ done
152+ docker buildx build . --file Dockerfile $FORMATTED_TAGS --push --platform=linux/arm64,linux/amd64
0 commit comments