Skip to content

Commit 06c159f

Browse files
committed
Tag management in GitHub action
1 parent f180df5 commit 06c159f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/group-sync-operator.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ jobs:
1616
run: make
1717
- name: Golang Test
1818
run: make test
19+
- name: Get the version
20+
id: get_version
21+
run: |
22+
# Version is based on a semantic version tag
23+
VERSION=${GITHUB_REF#refs/tags/}
24+
# Publish to latest, minor, and patch tags
25+
TAGS=('latest')
26+
# Add Tag is Exists
27+
if [ "$VERSION" != "$GITHUB_REF" ]; then
28+
TAGS=('latest' "${VERSION}")
29+
fi
30+
# Set IMAGE_TAGS output for use in next step
31+
( IFS=$','; echo "::set-output name=IMAGE_TAGS::${TAGS[*]}" )
1932
- name: "Build and Push Image"
2033
uses: docker/build-push-action@v1
2134
with:
@@ -24,5 +37,5 @@ jobs:
2437
password: ${{ secrets.OPERATOR_REGISTRY_PASSWORD }}
2538
registry: ${{ secrets.OPERATOR_REGISTRY_SERVER }}
2639
repository: ${{ secrets.OPERATOR_REGISTRY_REPOSITORY }}
27-
push: ${{ github.ref == 'refs/heads/master' && secrets.OPERATOR_REGISTRY_PUSH == 'true' }}
28-
tags: latest
40+
push: ${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && secrets.OPERATOR_REGISTRY_PUSH == 'true' }}
41+
tags: "${{ steps.get_version.outputs.IMAGE_TAGS }}"

0 commit comments

Comments
 (0)