1515jobs :
1616 build :
1717 runs-on : ubuntu-latest
18+ outputs :
19+ image_tag : ${{ steps.export-image-tag.outputs.image_tag }}
1820 # Use Production/Development environment so NEXTAUTH_URL (and other vars) are available for build-args when desired
1921 environment : ${{ github.ref == 'refs/heads/production' && 'Production' || 'Development' }}
2022 permissions :
9193 cache-from : type=gha
9294 cache-to : type=gha,mode=max
9395
96+ - name : Export image tag
97+ id : export-image-tag
98+ run : echo "image_tag=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
99+
94100 deploy :
101+ needs : build
95102 runs-on : ubuntu-latest
96103 environment : ${{ (github.event.workflow_run.head_branch == 'production' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/production')) && 'Production' || 'Development' }}
97104
@@ -259,7 +266,7 @@ jobs:
259266 export PAT="${{ secrets.PAT }}"
260267 export REGISTRY="${{ vars.REGISTRY || secrets.REGISTRY || 'ghcr.io' }}"
261268 export IMAGE_PREFIX="${{ vars.IMAGE_PREFIX || secrets.IMAGE_PREFIX || github.repository_owner }}"
262- export IMAGE_TAG="$DEPLOY_BRANCH "
269+ export IMAGE_TAG="${{ needs.build.outputs.image_tag }} "
263270 export SERVER_PORT="${{ vars.SERVER_PORT || secrets.SERVER_PORT || '8080' }}"
264271 export WEB_BACKEND_URL="http://web-backend:8000"
265272 export DEPLOY_ENVIRONMENT="${{ vars.DEPLOY_ENVIRONMENT }}"
@@ -268,7 +275,7 @@ jobs:
268275 # Deploy web, web-backend
269276 export COMPOSE_PROFILES="web,web-backend"
270277 SERVICES="web web-backend"
271- export IMAGE_TAG="$DEPLOY_BRANCH "
278+ export IMAGE_TAG="${{ needs.build.outputs.image_tag }} "
272279 echo ""
273280 echo "=========================================="
274281 echo "$ENV_EMOJI Starting Deployment to $DEPLOY_ENV"
0 commit comments