Skip to content

Commit 9da76b8

Browse files
committed
Run update
1 parent 66a7a7e commit 9da76b8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

index.js

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ host all all ::1/128 md5
6060
execSync(`echo "${contents}" | sudo tee ${dir}/pg_hba.conf`);
6161
}
6262

63+
function formulaPresent(formula) {
64+
const tapPrefix = process.arch == 'arm64' ? '/opt/homebrew' : '/usr/local/Homebrew';
65+
const tap = `${tapPrefix}/Library/Taps/homebrew/homebrew-core`;
66+
return fs.existsSync(`${tap}/Formula/${formula[0]}/${formula}.rb`) || fs.existsSync(`${tap}/Aliases/${formula}`);
67+
}
68+
6369
const defaultVersion = process.env['ImageOS'] == 'ubuntu24' ? 16 : 14;
6470
const postgresVersion = parseFloat(process.env['INPUT_POSTGRES-VERSION'] || defaultVersion);
6571
if (![18, 17, 16, 15, 14, 13, 12, 11, 10, 9.6].includes(postgresVersion)) {
@@ -82,6 +88,10 @@ if (isMac()) {
8288
run(`brew unlink postgresql@14`);
8389
}
8490

91+
if (!formulaPresent(`postgresql@${postgresVersion}`)) {
92+
run(`brew update`);
93+
}
94+
8595
// install new version
8696
run(`brew install postgresql@${postgresVersion}`);
8797
}

0 commit comments

Comments
 (0)