Copilot commented on code in PR #81:
URL:
https://github.com/apache/cloudstack-kubernetes-provider/pull/81#discussion_r2556637331
##########
.github/workflows/build-docker-image.yml:
##########
@@ -57,8 +50,41 @@ jobs:
- name: Set Docker image FULL TAG
run: echo "FULL_TAG=$(if [ "${{ secrets.DOCKER_REGISTRY }}" = ""
];then echo ${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};else
echo ${{ secrets.DOCKER_REGISTRY
}}/${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};fi)" >>
$GITHUB_ENV
- - name: Build the Docker image for cloudstack-kubernetes-provider
- run: docker build . --file Dockerfile --tag ${FULL_TAG}
+ - name: Check if should push
+ id: should_push
+ run: |
+ if [ "${{ github.event_name }}" != "pull_request" ] || [ "${{
github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}"
]; then
+ echo "should_push=true" >> $GITHUB_OUTPUT
+ else
+ echo "should_push=false" >> $GITHUB_OUTPUT
+ fi
- - name: Push Docker image to Docker Registry
- run: docker push ${FULL_TAG}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Registry
+ if: steps.should_push.outputs.should_push == 'true'
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ secrets.DOCKER_REGISTRY }}
+ username: ${{ secrets.DOCKERHUB_USER }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Set cache configuration
+ id: cache_config
+ run: |
+ if [ "${{ steps.should_push.outputs.should_push }}" == "true" ]; then
+ echo "cache_from=type=registry,ref=${FULL_TAG}-cache" >>
$GITHUB_OUTPUT
+ echo "cache_to=type=registry,ref=${FULL_TAG}-cache,mode=max" >>
$GITHUB_OUTPUT
+ fi
+
+ - name: Build and push Docker image for cloudstack-kubernetes-provider
(multi-arch)
+ uses: docker/build-push-action@v5
Review Comment:
[nitpick] The docker/build-push-action@v5 version is being used. Consider
using v6 which is the latest major version (as of 2025) and includes improved
performance and security features. However, verify compatibility with your
requirements before upgrading.
```suggestion
uses: docker/build-push-action@v6
```
##########
.github/workflows/build-docker-image.yml:
##########
@@ -57,8 +50,41 @@ jobs:
- name: Set Docker image FULL TAG
run: echo "FULL_TAG=$(if [ "${{ secrets.DOCKER_REGISTRY }}" = ""
];then echo ${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};else
echo ${{ secrets.DOCKER_REGISTRY
}}/${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};fi)" >>
$GITHUB_ENV
- - name: Build the Docker image for cloudstack-kubernetes-provider
- run: docker build . --file Dockerfile --tag ${FULL_TAG}
+ - name: Check if should push
+ id: should_push
+ run: |
+ if [ "${{ github.event_name }}" != "pull_request" ] || [ "${{
github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}"
]; then
+ echo "should_push=true" >> $GITHUB_OUTPUT
+ else
+ echo "should_push=false" >> $GITHUB_OUTPUT
+ fi
- - name: Push Docker image to Docker Registry
- run: docker push ${FULL_TAG}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Registry
+ if: steps.should_push.outputs.should_push == 'true'
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ secrets.DOCKER_REGISTRY }}
+ username: ${{ secrets.DOCKERHUB_USER }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Set cache configuration
+ id: cache_config
+ run: |
+ if [ "${{ steps.should_push.outputs.should_push }}" == "true" ]; then
Review Comment:
String comparison in bash should use single '=' instead of '=='. While '=='
works in bash, it's not POSIX-compliant. Line 56 correctly uses '==' which
works in the conditional expression '[[ ]]', but this script uses single
brackets '[ ]' which should use single '='.
```suggestion
if [ "${{ steps.should_push.outputs.should_push }}" = "true" ];
then
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]