Skip to content

Commit 6c7a151

Browse files
committed
refactor: deploy
1 parent c92fa65 commit 6c7a151

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

.github/workflows/shared-build-and-deploy.yaml

+11-10
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ jobs:
2525
packages: write
2626
outputs:
2727
image-node: ${{ steps.image-tag.outputs.image-node-service }}
28-
sha-short: ${{ steps.sha_short.outputs.sha_short }}
28+
sha-short: ${{ steps.vars.outputs.sha_short }}
2929
steps:
3030
- name: Checkout repository
3131
uses: actions/checkout@v4
3232

33-
- name: Set SHA_SHORT environment variable
34-
id: sha_short
35-
run: echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
36-
37-
- name: Check SHA_SHORT environment variable
38-
run: echo ${{ steps.sha_short.outputs.sha_short }}
33+
- name: Set sha-short and image-name environment variables
34+
id: vars
35+
run: |
36+
image_name=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.services.imageName }}" | tr '[:upper:]' '[:lower:]')
37+
echo "image_name=$image_name" >> $GITHUB_OUTPUT
38+
sha_short=$(git rev-parse --short HEAD) | tr '[:upper:]' '[:lower:]
39+
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
3940
4041
# Login against a Docker registry except on PR
4142
# https://github.com/docker/login-action
@@ -53,7 +54,7 @@ jobs:
5354
id: meta
5455
uses: docker/metadata-action@v5
5556
with:
56-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.services.imageName }}
57+
images: ${{ steps.vars.outputs.image_name }}
5758
tags: |
5859
type=semver,pattern={{version}}
5960
type=semver,pattern={{major}}.{{minor}}
@@ -75,8 +76,8 @@ jobs:
7576
- name: Output image tag
7677
id: image-tag
7778
run: |
78-
name=$(echo "image-${{ matrix.services.imageName }}" | tr '[:upper:]' '[:lower:]')
79-
value=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.services.imageName }}:sha-${{ steps.sha_short.outputs.sha_short }}" | tr '[:upper:]' '[:lower:]')
79+
name=$(echo "image-${{ steps.vars.outputs.image_name }}")
80+
value=$(echo "${{ steps.vars.outputs.image_name }}:sha-${{ steps.vars.outputs.sha_short }}"')
8081
echo "setting output: $name=$value"
8182
echo "$name=$value" >> $GITHUB_OUTPUT
8283

0 commit comments

Comments
 (0)