GeezerVison is showing github.com — Add token input for downloading release assets by TingluoHuang · Pull Request #851 · ruby/setup-ruby
Add token input for downloading release assets
#851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter
Filter by extension
.js
(5)
.md
(1)
.yml
(1)
All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
README.md
Original file line number
Diff line number
Diff line change
Expand Up
@@ -152,6 +152,23 @@ and the [condition and expression syntax](https://help.github.com/en/actions/ref
The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions`, `mise.toml` and `Gemfile.lock`
if they are not at the root of the repository, see [action.yml](action.yml) for details.
### Authentication Token
By default, this action uses `${{ github.token }}` to authenticate when downloading Ruby release assets from GitHub.
This helps avoid rate limiting issues.
If you're running this action on a GitHub Enterprise Server (GHES) instance, or if you're experiencing rate limiting,
you can provide a custom token:
```yaml
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
token: ${{ secrets.MY_GITHUB_TOKEN }}
```
In most cases, you don't need to set this input as the default value is sufficient for use on github.com.
Comment thread
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
I'll move this section further as the input is expected to be very rarely set.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
TingluoHuang reacted with thumbs up emoji
### RubyGems
By default, the default RubyGems version that comes with each Ruby is used.
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -44,6 +44,13 @@ inputs:
It also sets environment variables using 'ridk' or 'vcvars64.bat' based on the selected Ruby.
At present, the only other setting than 'default' is 'none', which only adds Ruby to PATH.
No build tools or packages are installed, nor are any ENV setting changed to activate them.
token:
description: |
Used to authenticate with GitHub when downloading Ruby release assets.
Since there is a default, this is typically not supplied by the user.
When running this action on github.com, the default value is sufficient.
When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
Comment thread
Comment on lines
+47
to
+52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
MSP-Greg reacted with eyes emoji
outputs:
ruby-prefix:
Expand Down
3 changes: 2 additions & 1 deletion
3
common.js
Original file line number
Diff line number
Diff line change
Expand Up
@@ -16,7 +16,8 @@ export const drive = (windows ? (process.env['RUNNER_TEMP'] || 'C')[0] : undefin
const PATH_ENV_VAR = windows ? 'Path' : 'PATH'
export const inputs = {
selfHosted: undefined
selfHosted: undefined,
token: undefined
}
export function partition(string, separator) {
Expand Down
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
2 changes: 2 additions & 0 deletions
2
index.js
Original file line number
Diff line number
Diff line change
Expand Up
@@ -18,6 +18,7 @@ const inputDefaults = {
'cache-version': bundler.DEFAULT_CACHE_VERSION,
'self-hosted': 'false',
'windows-toolchain': 'default',
'token': '',
}
// entry point when this action is run on its own
Expand Down
Expand Up
@@ -45,6 +46,7 @@ export async function setupRuby(options = {}) {
}
}
common.inputs.selfHosted = inputs['self-hosted']
common.inputs.token = inputs['token']
process.chdir(inputs['working-directory'])
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -74,8 +74,9 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) {
const downloadPath = await common.measure('Downloading Ruby', async () => {
const url = getDownloadURL(platform, engine, version)
console.log(url)
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
try {
return await tc.downloadTool(url)
return await tc.downloadTool(url, undefined, auth )
} catch (error) {
if (error.message.includes('404')) {
throw new Error(`Unavailable version ${version} for ${engine} on ${platform}
Expand Down
12 changes: 8 additions & 4 deletions
12
windows.js
Original file line number
Diff line number
Diff line change
Expand Up
@@ -81,7 +81,8 @@ export async function install(platform, engine, version) {
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
const downloadPath = await common.measure('Downloading Ruby', async () => {
console.log(url)
return await tc.downloadTool(url)
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
return await tc.downloadTool(url, undefined, auth)
})
const extractPath = process.env.RUNNER_TEMP
Expand Down
Expand Up
@@ -113,7 +114,8 @@ export async function installJRubyTools() {
async function installMSYS2(url, rubyPrefix = process.env.RUNNER_TEMP) {
const downloadPath = await common.measure('Downloading msys2 build tools', async () => {
console.log(url)
return await tc.downloadTool(url)
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
return await tc.downloadTool(url, undefined, auth)
})
const extractPath = path.join(process.env.RUNNER_TEMP, 'msys64')
Expand Down
Expand Up
@@ -160,7 +162,8 @@ async function installMSYS1(url) {
const downloadPath = await common.measure('Downloading msys1 build tools', async () => {
console.log(url)
return await tc.downloadTool(url)
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
return await tc.downloadTool(url, undefined, auth)
})
const msys1Path = `${common.drive}:\\DevKit64`
Expand Down
Expand Up
@@ -196,7 +199,8 @@ async function installMSYS1(url) {
async function installVCPKG(url) {
const downloadPath = await common.measure('Downloading mswin vcpkg packages', async () => {
console.log(url)
return await tc.downloadTool(url)
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
return await tc.downloadTool(url, undefined, auth)
})
const extractPath = process.env.VCPKG_INSTALLATION_ROOT
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.