@@ -38,6 +38,9 @@ inputs:
3838 description : ' Image provider (only for Nuxt)'
3939 required : false
4040 default : ' ipx'
41+ docker_buildargs :
42+ description : ' List of additional ENVs that should be passed at Docker image build-time'
43+ required : false
4144runs :
4245 using : ' composite'
4346 steps :
@@ -52,27 +55,59 @@ runs:
5255 username : ${{ inputs.cloud_username }}
5356 password : ${{ inputs.cloud_password }}
5457
55- - name : Resolve values of the versions, docker ref & dockerfile path
58+ - name : Resolve docker buildargs
5659 id : resolve
57- shell : bash
58- run : |
59- # Set the version of the app based on user input or use git commit hash
60- echo "version=${{ inputs.version || github.sha }}" >> $GITHUB_OUTPUT
61- # Set the reference address for app in docker registry
62- echo "ref=${{ inputs.docker_registry_url }}/${{ inputs.project_name }}-storefrontcloud-io" >> $GITHUB_OUTPUT
63- # Set the path to the Dockerfile base on selected frontend framework
64- if [[ $FRONTEND == "next" ]]; then
65- echo "path=.vuestorefrontcloud/docker/nextjs/Dockerfile-frontend" >> $GITHUB_OUTPUT
66- elif [[ $FRONTEND == "nextjs" ]]; then
67- echo "path=.vuestorefrontcloud/docker/nextjs/Dockerfile-frontend" >> $GITHUB_OUTPUT
68- elif [[ $FRONTEND == "nuxt" ]]; then
69- echo "path=.vuestorefrontcloud/docker/nuxtjs/Dockerfile-frontend" >> $GITHUB_OUTPUT
70- else
71- echo "Error: Unsupported FRONTEND value. Valid options are 'next' or 'nuxt'."
72- exit 1
73- fi
60+ uses : actions/github-script@v7
7461 env :
75- FRONTEND : ${{ inputs.frontend }}
62+ INPUT_NPM_EMAIL : ${{ inputs.npm_email }}
63+ INPUT_NPM_PASS : ${{ inputs.npm_pass }}
64+ INPUT_NPM_USER : ${{ inputs.npm_user }}
65+ INPUT_NPM_REGISTRY : ${{ inputs.npm_registry }}
66+ INPUT_IMAGE_PROVIDER : ${{ inputs.image_provider }}
67+ INPUT_DOCKER_BUILDARGS : ${{ inputs.docker_buildargs }}
68+ INPUT_FRONTEND : ${{ inputs.frontend }}
69+ INPUT_VERSION : ${{ inputs.version }}
70+ INPUT_DOCKER_REGISTRY_URL : ${{ inputs.docker_registry_url }}
71+ INPUT_PROJECT_NAME : ${{ inputs.project_name }}
72+ with :
73+ result-encoding : string
74+ script : |
75+ const base = {
76+ 'NPM_EMAIL': core.getInput('npm_email'),
77+ 'NPM_PASS': core.getInput('npm_pass'),
78+ 'NPM_USER': core.getInput('npm_user'),
79+ 'NPM_REGISTRY': core.getInput('npm_registry'),
80+ 'NUXT_IMAGE_PROVIDER': core.getInput('image_provider'),
81+ };
82+
83+ const transformedBaseArgs = Object.entries(base)
84+ .map(([key, value]) => `${key}=${value}`);
85+
86+ const extraArgs = core.getMultilineInput('docker_buildargs', { required: false });
87+ const mergedArgs = [
88+ ...transformedBaseArgs,
89+ ...extraArgs,
90+ ];
91+
92+ core.setOutput('docker_args', mergedArgs.join('\n'));
93+
94+ const versionInput = core.getInput('version');
95+ core.setOutput('version', versionInput || context.sha);
96+
97+ core.setOutput('ref', `${core.getInput('docker_registry_url')}/${core.getInput('project_name')}-storefrontcloud-io`);
98+
99+ const frontendInput = core.getInput('frontend');
100+
101+ switch (frontendInput) {
102+ case "next":
103+ core.setOutput('path', '.vuestorefrontcloud/docker/nextjs/Dockerfile-frontend');
104+ break;
105+ case "nuxt":
106+ core.setOutput('path', '.vuestorefrontcloud/docker/nuxtjs/Dockerfile-frontend');
107+ break;
108+ default:
109+ core.setOutput('path', '.vuestorefrontcloud/docker/nextjs/Dockerfile-frontend')
110+ }
76111
77112 - name : Check for existing image
78113 id : check-existing-image
92127 tags : ${{ steps.resolve.outputs.ref }}/vue-storefront:${{ steps.resolve.outputs.version }}
93128 cache-from : " type=registry,ref=${{ steps.resolve.outputs.ref }}/vue-storefront:buildcache"
94129 cache-to : " type=registry,ref=${{ steps.resolve.outputs.ref }}/vue-storefront:buildcache,mode=max"
95- build-args : |
96- NPM_EMAIL=${{ inputs.npm_email }}
97- NPM_PASS=${{ inputs.npm_pass }}
98- NPM_USER=${{ inputs.npm_user }}
99- NPM_REGISTRY=${{ inputs.npm_registry }}
100- NUXT_IMAGE_PROVIDER=${{ inputs.image_provider }}
130+ build-args : ${{ steps.resolve.outputs.docker_args }}
0 commit comments