@@ -385,13 +385,35 @@ runs:
385385
386386 - id : detect-docker
387387 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
388+ env :
389+ # FIXME: upgrade version when available (https://hub.docker.com/r/dockereng/cli-bin/tags)
390+ EXPECTED_DOCKER_VERSION : 29.5.2
388391 with :
389392 script : |
390393 const dockerPath = await io.which('docker', false);
391- core.setOutput('exists', dockerPath ? 'true' : 'false');
392394
393- - if : steps.detect-docker.outputs.exists != 'true'
395+ if (!dockerPath) {
396+ core.setOutput('docker-install-version', process.env.EXPECTED_DOCKER_VERSION);
397+ return;
398+ }
399+
400+ try {
401+ const { stdout } = await exec.getExecOutput('docker', ['version', '--format', '{{.Server.Version}}']);
402+ const dockerVersion = stdout.trim();
403+
404+ // Check if the detected Docker version is the same as the expected version.
405+ if (dockerVersion !== process.env.EXPECTED_DOCKER_VERSION) {
406+ core.setOutput('docker-install-version', process.env.EXPECTED_DOCKER_VERSION);
407+ }
408+ } catch (error) {
409+ core.warning(`Failed to detect Docker version, defaulting to expected version: ${error}`);
410+ core.setOutput('docker-install-version', process.env.EXPECTED_DOCKER_VERSION);
411+ };
412+
413+ - if : steps.detect-docker.outputs.docker-install-version
394414 uses : docker/setup-docker-action@0234bb73ccb40f0c430b795634f9247e2b5c2d23 # v5.2.0
415+ with :
416+ version : ${{ steps.detect-docker.outputs.docker-install-version }}
395417
396418 - if : inputs.setup-buildx != 'false'
397419 uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
0 commit comments