Skip to content

Commit 3a0456b

Browse files
committed
refactor: deploy
1 parent c92fa65 commit 3a0456b

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

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

+14-18
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ jobs:
2424
contents: read
2525
packages: write
2626
outputs:
27-
image-node: ${{ steps.image-tag.outputs.image-node-service }}
28-
sha-short: ${{ steps.sha_short.outputs.sha_short }}
27+
image-name: ${{ steps.vars.outputs.image_name }}
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=$(echo "$(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}}
@@ -72,14 +73,6 @@ jobs:
7273
tags: ${{ steps.meta.outputs.tags }}
7374
labels: ${{ steps.meta.outputs.labels }}
7475

75-
- name: Output image tag
76-
id: image-tag
77-
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:]')
80-
echo "setting output: $name=$value"
81-
echo "$name=$value" >> $GITHUB_OUTPUT
82-
8376
deploy:
8477
runs-on: ubuntu-latest
8578
if: github.event_name != 'pull_request'
@@ -108,13 +101,16 @@ jobs:
108101
DEPLOYMENT_NAME="${REF_SHA////-}"
109102
echo "DEPLOYMENT_NAME=$DEPLOYMENT_NAME"
110103
104+
webServiceImage="${{ needs.build.outputs.image-name }}:sha-${{ needs.build.outputs.sha-short }}"
105+
echo "webServiceImage=$webServiceImage"
106+
111107
TAGS='{"owner":"johnnyreilly", "email":"johnny_reilly@hotmail.com"}'
112108
az deployment group create \
113109
--resource-group ${{ env.RESOURCE_GROUP }} \
114110
--name "$DEPLOYMENT_NAME" \
115111
--template-file ./infra/main.bicep \
116112
--parameters \
117-
webServiceImage='${{ needs.build.outputs.image-node }}' \
113+
webServiceImage="$webServiceImage" \
118114
containerRegistry=${{ env.REGISTRY }} \
119115
containerRegistryUsername=${{ github.actor }} \
120116
containerRegistryPassword=${{ secrets.PACKAGES_TOKEN }} \

0 commit comments

Comments
 (0)