Skip to content

Commit

Permalink
fix: add secondary tags for build performance
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 committed Feb 27, 2024
1 parent 7cd7504 commit 3e6757d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .github/actions/determine-docker-image-tag/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ runs:
fi
fi
primary_tag=$(echo ${tags} | awk '{print $1}')
secondary_tags=$(echo ${tags} | awk '{$1=""; print substr($0,2)}')
echo "Determined tags: ${tags}"
echo "Primary tag: ${primary_tag}"
echo "Secondary tags: ${secondary_tags}"
echo "TAGS=${tags}" >> $GITHUB_OUTPUT
echo "PRIMARY_TAG=${primary_tag}" >> $GITHUB_OUTPUT
echo "TAGS=${tags}" >> $GITHUB_OUTPUT
echo "PRIMARY_TAG=${primary_tag}" >> $GITHUB_OUTPUT
echo "SECONDARY_TAGS=${secondary_tags}" >> $GITHUB_OUTPUT
8 changes: 3 additions & 5 deletions .github/actions/docker-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ runs:
shell: bash
id: add_extra_tags
run: |
if [[ "${{ github.event_name }}" = "pull_request" || "${{ github.event_name }}" = "pull_request_target" ]]; then
extra_tags="-t ${IMAGE_NAME}:${PRIMARY_TAG} -t ${ALTER_IMAGE_NAME}:${PRIMARY_TAG}"
else
for tag in ${TAGS}; do
if [[ "${{ github.event_name }}" != "pull_request" && "${{ github.event_name }}" != "pull_request_target" ]]; then
for tag in ${SECONDARY_TAGS}; do
extra_tags="${extra_tags} -t ${IMAGE_NAME}:${tag} -t ${ALTER_IMAGE_NAME}:${tag}"
done
fi
Expand All @@ -106,7 +104,7 @@ runs:
env:
IMAGE_NAME: ${{ steps.image_name.outputs.IMAGE_NAME }}
ALTER_IMAGE_NAME: ${{ steps.image_name.outputs.ALTER_IMAGE_NAME }}
TAGS: ${{ steps.determine_tag_name.outputs.TAGS }}
SECONDARY_TAGS: ${{ steps.determine_tag_name.outputs.SECONDARY_TAGS }}
PRIMARY_TAG: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }}
- name: Build and Push
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion Makefile.d/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ ifeq ($(REMOTE),true)
--build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \
--build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \
--build-arg MAINTAINER=$(MAINTAINER) \
$(EXTRA_ARGS) \
--sbom=true \
--provenance=mode=max \
-t $(CRORG)/$(IMAGE):$(TAG) \
-t $(GHCRORG)/$(IMAGE):$(TAG) \
$(EXTRA_ARGS) \
--output type=registry,oci-mediatypes=true,compression=zstd,compression-level=5,force-compression=true,push=true \
-f $(DOCKERFILE) .
else
Expand Down

0 comments on commit 3e6757d

Please sign in to comment.