Skip to content

Commit 8c073b9

Browse files
committed
Checkout code before calculating git sha
* This is required to ref-parse the tag
1 parent 5dd939b commit 8c073b9

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Deploy
2-
run-name: Deploy to ${{ inputs.environment }}
2+
run-name: Deploy ${{ inputs.git_tag || github.ref_name }} to ${{ inputs.environment }}
33

44
concurrency:
55
group: deploy-${{ inputs.environment }}
@@ -47,16 +47,21 @@ jobs:
4747
outputs:
4848
git-sha: ${{ steps.get-git-sha.outputs.git-sha }}
4949
steps:
50-
- name: Get git sha
51-
id: get-git-sha
52-
run: |
53-
if [ -z "${{ inputs.git_tag }}" ]; then
54-
echo "No git tag provided. Using the latest commit sha"
55-
echo "git-sha=${{ github.sha }}" >> $GITHUB_OUTPUT
56-
else
57-
echo "Git tag provided. Using the sha of the tagged commit"
58-
echo "git-sha=$(git rev-parse ${{ inputs.git_tag }})" >> $GITHUB_OUTPUT
59-
fi
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
with:
53+
ref: ${{ inputs.git_tag || github.sha }}
54+
- name: Get git sha
55+
id: get-git-sha
56+
run: |
57+
if [ -z "${{ inputs.git_tag }}" ]; then
58+
echo "No git tag provided. Using the latest commit sha"
59+
echo "git-sha=${{ github.sha }}" >> $GITHUB_OUTPUT
60+
else
61+
git_sha=$(git rev-parse refs/tags/${{ inputs.git_tag }})
62+
echo "Git tag provided. Using the sha of the tagged commit: $git_sha"
63+
echo "git-sha=$git_ssha" >> $GITHUB_OUTPUT
64+
fi
6065
build-and-push-image:
6166
needs: determine-git-sha
6267
uses: ./.github/workflows/build-and-push-image.yml

0 commit comments

Comments
 (0)