Skip to content

Commit

Permalink
Allow running external function before 'bundle install'
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
MSP-Greg authored and eregon committed Jul 1, 2020
1 parent 5c4fc21 commit 271876d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const inputDefaults = {
// entry point when this action is run on its own
export async function run() {
try {
await setupRuby({})
await setupRuby()
} catch (error) {
core.setFailed(error.message)
}
}

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

setupPath(newPathEntries)

// When setup-ruby is used by other actions, this allows code in them to run
// before 'bundle install'. Installed dependencies may require additional
// libraries & headers, build tools, etc.
if (inputs['afterSetupPathHook'] instanceof Function) {
await inputs['afterSetupPathHook']({ platform, rubyPrefix, engine, version })
}

if (inputs['bundler'] !== 'none') {
await common.measure('Installing Bundler', async () =>
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))
Expand Down

0 comments on commit 271876d

Please sign in to comment.