Skip to content

Commit 1215fce

Browse files
authored
fix(ci): rework get latest tag for build Docker image (#954)
* fix getting tag when building container * add debug informations * fix debug output
1 parent 5cb881b commit 1215fce

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/docker-goss.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ jobs:
4545
ghcr.io/${{ github.repository_owner }}/goss
4646
4747
- name: Get latest git tag
48-
uses: actions-ecosystem/action-get-latest-tag@v1
48+
if: github.ref_name == 'master'
4949
id: get-latest-tag
50+
run: |
51+
# source: https://github.com/actions-ecosystem/action-get-latest-tag/blob/main/entrypoint.sh
52+
set -e
53+
git config --global --add safe.directory /github/workspace
54+
git fetch --tags --force
55+
# This suppress an error occurred when the repository is a complete one.
56+
git fetch --prune --unshallow 2>/dev/null || true
57+
latest_tag=$(git describe --abbrev=0 --tags || true)
58+
echo "tag=${latest_tag}" >> "$GITHUB_OUTPUT"
59+
echo "Latest tag: $latest_tag"
5060
5161
- name: Set short git commit SHA
62+
if: github.ref_name == 'master'
5263
run: |
5364
calculatedSha=$(git rev-parse --short ${{ github.sha }})
5465
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
66+
echo "COMMIT_SHORT_SHA: $calculatedSha"
5567
5668
- name: Get the current version of Go from project.
5769
run: echo "GO_VERSION_FROM_PROJECT=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

0 commit comments

Comments
 (0)