Skip to content

Commit 77a546c

Browse files
committed
add hook for setup script
This gives you the ability to pass script text to the `setup-ruby` action. The script will be executed after Ruby and Bundler are installed, but before `bundle install` is run. If you want to execute a script on disk, just pass the filename, like `'./setup.sh'` or `'ruby setup.rb'` If you intend to use this to install a custom Bundler version or the like, make sure to specify `bundler: none` so you don't get a second version installed.
1 parent 90be115 commit 77a546c

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ inputs:
1515
For 'latest', `gem update --system` is run to update to the latest compatible RubyGems version.
1616
Ruby head/master builds will not be updated.
1717
Similarly, if a version number is given, `gem update --system <version>` is run to update to that version of RubyGems, as long as that version is newer than the one provided by default.
18+
setup-script:
19+
description: |
20+
Setup code to be executed after Ruby and Bundler are installed, but before `bundle install` is run.
21+
If you want to execute a script on disk, just pass the filename, like `'./setup.sh'` or `'ruby setup.rb'`
22+
If you intend to use this to install a custom Bundler version or the like, make sure to specify `bundler: none`.
1823
bundler:
1924
description: |
2025
The version of Bundler to install. Either 'Gemfile.lock' (the default), 'default', 'latest', 'none', or a version number (e.g., 1, 2, 2.1, 2.1.4).

dist/index.js

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

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const inputDefaults = {
1414
'rubygems': 'default',
1515
'bundler': 'Gemfile.lock',
1616
'bundler-cache': 'false',
17+
'setup-script': '',
1718
'working-directory': '.',
1819
'cache-version': bundler.DEFAULT_CACHE_VERSION,
1920
'self-hosted': 'false',
@@ -98,6 +99,15 @@ export async function setupRuby(options = {}) {
9899
bundler.installBundler(inputs['bundler'], rubygemsInputSet, lockFile, platform, rubyPrefix, engine, version))
99100
}
100101

102+
if (inputs['setup-script'] !== '') {
103+
await common.measure('Running setup script', async () => {
104+
const lines = inputs['setup-script'].split(/\r?\n/)
105+
for (const line of lines) {
106+
await exec.exec(line)
107+
}
108+
})
109+
}
110+
101111
if (inputs['bundler-cache'] === 'true') {
102112
await common.time('bundle install', async () =>
103113
bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version']))

0 commit comments

Comments
 (0)