@@ -13,6 +13,24 @@ import * as fs from 'fs'
13
13
const flavor = core . getInput ( 'flavor' )
14
14
const architecture = core . getInput ( 'architecture' )
15
15
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
+
16
34
async function run ( ) : Promise < void > {
17
35
try {
18
36
if ( process . platform !== 'win32' ) {
@@ -37,7 +55,8 @@ async function run(): Promise<void> {
37
55
architecture ,
38
56
githubToken
39
57
)
40
- const outputDirectory = core . getInput ( 'path' ) || `C:/${ artifactName } `
58
+ const outputDirectory =
59
+ core . getInput ( 'path' ) || `${ getDriveLetterPrefix ( ) } ${ artifactName } `
41
60
let useCache : boolean
42
61
switch ( core . getInput ( 'cache' ) ) {
43
62
case 'true' :
@@ -153,7 +172,9 @@ function cleanup(): void {
153
172
154
173
const outputDirectory =
155
174
core . getInput ( 'path' ) ||
156
- `C:/${ getArtifactMetadata ( flavor , architecture ) . artifactName } `
175
+ `${ getDriveLetterPrefix ( ) } ${
176
+ getArtifactMetadata ( flavor , architecture ) . artifactName
177
+ } `
157
178
158
179
/**
159
180
* Shelling out to `rm -rf` is more than twice as fast as Node's `fs.rmSync` method.
0 commit comments