@@ -13,6 +13,24 @@ import * as fs from 'fs'
1313const flavor = core . getInput ( 'flavor' )
1414const architecture = core . getInput ( 'architecture' )
1515
16+ /**
17+ * Some Azure VM types have a temporary disk which is local to the VM and therefore provides
18+ * _much_ faster disk IO than the OS Disk (or any other attached disk).
19+ *
20+ * Hosted GitHub Actions runners also leverage this disk and do their work in D:/a/_work, so let's
21+ * use it too if we can. It leads to a ~25% speed increase when doing heavy IO operations.
22+ *
23+ * https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#temporary-disk
24+ */
25+ function getDriveLetterPrefix ( ) : string {
26+ if ( fs . existsSync ( 'D:/' ) ) {
27+ core . info ( 'Found a fast, temporary disk on this VM (D:/). Will use that.' )
28+ return 'D:/'
29+ }
30+
31+ return 'C:/'
32+ }
33+
1634async function run ( ) : Promise < void > {
1735 try {
1836 if ( process . platform !== 'win32' ) {
@@ -37,7 +55,8 @@ async function run(): Promise<void> {
3755 architecture ,
3856 githubToken
3957 )
40- const outputDirectory = core . getInput ( 'path' ) || `C:/${ artifactName } `
58+ const outputDirectory =
59+ core . getInput ( 'path' ) || `${ getDriveLetterPrefix ( ) } ${ artifactName } `
4160 let useCache : boolean
4261 switch ( core . getInput ( 'cache' ) ) {
4362 case 'true' :
@@ -153,7 +172,9 @@ function cleanup(): void {
153172
154173 const outputDirectory =
155174 core . getInput ( 'path' ) ||
156- `C:/${ getArtifactMetadata ( flavor , architecture ) . artifactName } `
175+ `${ getDriveLetterPrefix ( ) } ${
176+ getArtifactMetadata ( flavor , architecture ) . artifactName
177+ } `
157178
158179 /**
159180 * Shelling out to `rm -rf` is more than twice as fast as Node's `fs.rmSync` method.
0 commit comments