Skip to content

Commit 271876d

Browse files
MSP-Gregeregon
authored andcommitted
Allow running external function before 'bundle install'
External actions may use setup-ruby, and some actions make changes/additions to the build environment. These may be needed for dependencies. Hence, allow those external actions to run code before 'bundle install'. This is done by passing a function as a parameter to setupRuby().
1 parent 5c4fc21 commit 271876d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

dist/index.js

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

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ const inputDefaults = {
1616
// entry point when this action is run on its own
1717
export async function run() {
1818
try {
19-
await setupRuby({})
19+
await setupRuby()
2020
} catch (error) {
2121
core.setFailed(error.message)
2222
}
2323
}
2424

2525
// entry point when this action is run from other actions
26-
export async function setupRuby(options) {
26+
export async function setupRuby(options = {}) {
2727
const inputs = { ...options }
2828
for (const key in inputDefaults) {
2929
if (!inputs.hasOwnProperty(key)) {
@@ -52,6 +52,13 @@ export async function setupRuby(options) {
5252

5353
setupPath(newPathEntries)
5454

55+
// When setup-ruby is used by other actions, this allows code in them to run
56+
// before 'bundle install'. Installed dependencies may require additional
57+
// libraries & headers, build tools, etc.
58+
if (inputs['afterSetupPathHook'] instanceof Function) {
59+
await inputs['afterSetupPathHook']({ platform, rubyPrefix, engine, version })
60+
}
61+
5562
if (inputs['bundler'] !== 'none') {
5663
await common.measure('Installing Bundler', async () =>
5764
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))

0 commit comments

Comments
 (0)