diff --git a/action.yml b/action.yml index 14732f8a5..b2ea56787 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,11 @@ inputs: to invalidate the cache. required: false default: '0' + post-ruby-install: + description: | + Execute a shell command after installing Ruby but before installing non-default Bundler gem. + Ignored if `input.bundler` is set to 'none'. + required: false outputs: ruby-prefix: description: 'The prefix of the installed ruby' diff --git a/index.js b/index.js index 7a1b0c8b5..eb3a3b63c 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ const os = require('os') const fs = require('fs') const path = require('path') const core = require('@actions/core') +const exec = require('@actions/exec') const common = require('./common') const bundler = require('./bundler') @@ -13,6 +14,7 @@ const inputDefaults = { 'bundler-cache': 'true', 'working-directory': '.', 'cache-version': bundler.DEFAULT_CACHE_VERSION, + 'post-ruby-install': null, } // entry point when this action is run on its own @@ -61,6 +63,14 @@ export async function setupRuby(options = {}) { } if (inputs['bundler'] !== 'none') { + // Similar to 'afterSetupPathHook' but for use within the Runner environment directly by end-user. + // If Bundler isn't being installed, this hook is redundant because the user is then free to execute + // their script in a separate `job.step`. + if (inputs['post-ruby-install']) { + await common.measure('Running Post Ruby Install Hook', async () => + await exec.exec(inputs['post-ruby-install'])) + } + const [gemfile, lockFile] = bundler.detectGemfiles() const bundlerVersion = await common.measure('Installing Bundler', async () =>