Skip to content

Commit 19528a9

Browse files
authored
Merge pull request #479 from dscho/use-agents-git
Prefer the build agent's copy of Git, fix `save-state` warning
2 parents bf0a74b + 10a04dc commit 19528a9

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

dist/index.js

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
gitForWindowsUsrBinPath
1010
} from './src/git'
1111
import * as fs from 'fs'
12-
import * as coreCommand from '@actions/core/lib/command'
1312

1413
const flavor = core.getInput('flavor')
1514
const architecture = core.getInput('architecture')
@@ -252,16 +251,16 @@ function cleanup(): void {
252251
/**
253252
* Indicates whether the POST action is running
254253
*/
255-
export const isPost = !!process.env['STATE_isPost']
254+
export const isPost = !!core.getState('isPost')
256255

257256
if (!isPost) {
258257
run()
259258
/*
260259
* Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
261260
* This is necessary since we don't have a separate entry point.
262-
* Inspired by https://github.com/actions/checkout/blob/v3.0.2/src/state-helper.ts#L69-L71
261+
* Inspired by https://github.com/actions/checkout/blob/v3.1.0/src/state-helper.ts#L56-L60
263262
*/
264-
coreCommand.issueCommand('save-state', {name: 'isPost'}, 'true')
263+
core.saveState('isPost', 'true')
265264
} else {
266265
// If the POST action is running, we cleanup our artifacts
267266
cleanup()

src/git.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ import {Octokit} from '@octokit/rest'
44
import {delimiter} from 'path'
55
import * as fs from 'fs'
66

7-
export const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
8-
const gitExePath = 'C:/Program Files/Git/cmd/git.exe'
7+
// If present, do prefer the build agent's copy of Git
8+
const externalsGitDir = `${process.env.AGENT_HOMEDIRECTORY}/externals/git`
9+
const gitForWindowsRoot = 'C:/Program Files/Git'
10+
const gitRoot = fs.existsSync(externalsGitDir)
11+
? externalsGitDir
12+
: gitForWindowsRoot
13+
14+
export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin`
15+
const gitExePath = `${gitRoot}/cmd/git.exe`
916

1017
/*
1118
* It looks a bit ridiculous to use 56 workers on a build agent that has only

0 commit comments

Comments
 (0)