@@ -34,6 +34,11 @@ import {Util} from '../util';
3434import { limaYamlData , dockerServiceLogsPs1 , setupDockerWinPs1 } from './assets' ;
3535import { GitHubRelease } from '../types/github' ;
3636import { HubRepository } from '../hubRepository' ;
37+ import { Index } from '../types/oci' ;
38+ import { MEDIATYPE_IMAGE_INDEX_V1 } from '../types/oci/mediatype' ;
39+ import { MEDIATYPE_IMAGE_MANIFEST_LIST_V2 } from '../types/docker/mediatype' ;
40+ import { Manifest } from '../types/oci/manifest' ;
41+ import { ImageConfig } from '../types/oci/config' ;
3742
3843export interface InstallSourceImage {
3944 type : 'image' ;
@@ -71,6 +76,8 @@ export class Install {
7176 private _version : string | undefined ;
7277 private _toolDir : string | undefined ;
7378
79+ private gitCommit : string | undefined ;
80+
7481 private readonly limaInstanceName = 'docker-actions-toolkit' ;
7582
7683 constructor ( opts : InstallOpts ) {
@@ -127,12 +134,24 @@ export class Install {
127134 const cli = await HubRepository . build ( 'dockereng/cli-bin' ) ;
128135 extractFolder = await cli . extractImage ( tag ) ;
129136
137+ const moby = await HubRepository . build ( 'moby/moby-bin' ) ;
130138 if ( [ 'win32' , 'linux' ] . includes ( platform ) ) {
131139 core . info ( `Downloading dockerd from moby/moby-bin:${ tag } ` ) ;
132- const moby = await HubRepository . build ( 'moby/moby-bin' ) ;
133140 await moby . extractImage ( tag , extractFolder ) ;
134141 } else if ( platform == 'darwin' ) {
135- // On macOS, the docker daemon binary will be downloaded inside the lima VM
142+ // On macOS, the docker daemon binary will be downloaded inside the lima VM.
143+ // However, we will get the exact git revision from the image config
144+ // to get the matching systemd unit files.
145+ const manifest = await moby . getPlatformManifest ( tag ) ;
146+ const config = await moby . getConfig < ImageConfig > ( manifest . config . digest ) ;
147+
148+ core . info ( `Docker image config labels: ${ JSON . stringify ( config . Labels , null , 2 ) } ` ) ;
149+ this . gitCommit = config . Labels ?. [ 'org.opencontainers.image.revision' ] ;
150+ if ( ! this . gitCommit ) {
151+ core . warning ( `No git revision can be determined from the image. Will use master.` ) ;
152+ this . gitCommit = 'master' ;
153+ }
154+ core . info ( `Git revision is ${ this . gitCommit } ` ) ;
136155 } else {
137156 core . warning ( `dockerd not supported on ${ platform } , only the Docker cli will be available` ) ;
138157 }
@@ -193,6 +212,9 @@ export class Install {
193212 }
194213
195214 private async installDarwin ( ) : Promise < string > {
215+ if ( ! this . gitCommit ) {
216+ throw new Error ( 'gitCommit must be set. Run download first.' ) ;
217+ }
196218 const src = this . source ;
197219 const limaDir = path . join ( os . homedir ( ) , '.lima' , this . limaInstanceName ) ;
198220 await io . mkdirP ( limaDir ) ;
@@ -229,6 +251,7 @@ export class Install {
229251 customImages : Install . limaCustomImages ( ) ,
230252 daemonConfig : limaDaemonConfig ,
231253 dockerSock : `${ limaDir } /docker.sock` ,
254+ gitCommit : this . gitCommit ,
232255 srcType : src . type ,
233256 srcArchiveVersion : this . _version , // Use the resolved version (e.g. latest -> 27.4.0)
234257 srcArchiveChannel : srcArchive . channel ,
0 commit comments