@@ -113,9 +113,16 @@ jobs:
113113 if : ${{ steps.detect-base-image-changes.outputs.BASE_IMAGE_CHANGE == 'true' || github.ref == 'refs/heads/main' }}
114114 continue-on-error : false
115115 run : |
116+
117+ echo "The branch is: ${GITHUB_REF}"
118+
116119 PR_NUM_TAG=$(echo "${GITHUB_REF}" | sed 's/refs\/pull\/\([0-9]*\)\/merge/\1/')
117120 SHORT_COMMIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
118121
122+ if [ "${GITHUB_REF}" == 'refs/heads/main' ]; then
123+ PR_NUM_TAG="main"
124+ fi
125+
119126 docker build -f Dockerfile.dotnet.base -t cohort-manager-dotnet-base:latest .
120127 docker tag cohort-manager-dotnet-base:latest "ghcr.io/nhsdigital/cohort-manager-dotnet-base:${PR_NUM_TAG}"
121128 docker tag cohort-manager-dotnet-base:latest "ghcr.io/nhsdigital/cohort-manager-dotnet-base:${SHORT_COMMIT_HASH}"
@@ -126,8 +133,10 @@ jobs:
126133
127134 docker push "ghcr.io/nhsdigital/cohort-manager-dotnet-base:${PR_NUM_TAG}"
128135 docker push "ghcr.io/nhsdigital/cohort-manager-dotnet-base:${SHORT_COMMIT_HASH}"
136+
129137 docker push "ghcr.io/nhsdigital/cohort-manager-function-base:${PR_NUM_TAG}"
130138 docker push "ghcr.io/nhsdigital/cohort-manager-function-base:${SHORT_COMMIT_HASH}"
139+
131140 if [ "${GITHUB_REF}" == 'refs/heads/main' ]; then
132141 docker push "ghcr.io/nhsdigital/cohort-manager-dotnet-base:latest"
133142 docker push "ghcr.io/nhsdigital/cohort-manager-function-base:latest"
@@ -143,6 +152,11 @@ jobs:
143152 if [[ ${{steps.detect-base-image-changes.outputs.BASE_IMAGE_CHANGE}} == 'true' ]]; then
144153 IMAGE_TAG="${PR_NUM_TAG}"
145154 fi
155+
156+ if [ "${GITHUB_REF}" == 'refs/heads/main' ]; then
157+ IMAGE_TAG="latest"
158+ fi
159+
146160 echo "Image Tag = ${IMAGE_TAG}"
147161
148162 echo "DOTNET_BASE_IMAGE=ghcr.io/nhsdigital/cohort-manager-dotnet-base:${IMAGE_TAG}" >> "${GITHUB_OUTPUT}"
0 commit comments