Use github token by default to authenticate download (#11)

This commit is contained in:
Simon Sorensen
2023-02-11 15:57:03 +02:00
committed by GitHub
parent 95b912dc5d
commit ad659545e1
6 changed files with 39 additions and 20 deletions
+15 -6
View File
@@ -24,9 +24,9 @@ If you want a specific version of `just` you can specify this by passing the
just-version: '1.4.0'
```
In rare circumstances you might get rate limiting errors, this is because this
workflow has to make requests to GitHub API in order to list available releases.
If this happens you can set the `GITHUB_TOKEN` environment variable.
To avoid rate-limitting, the default Github token available to all actions, is
automatically used to authenticate calls to Github. To override it, set the environment
variable `GITHUB_TOKEN`.
```yaml
- uses: extractions/setup-just@v1
@@ -34,11 +34,20 @@ If this happens you can set the `GITHUB_TOKEN` environment variable.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Alternatively, you may set the input `token`.
```yaml
- uses: extractions/setup-just@v1
input:
github-token: ${{ secrets.MY_GITHUB_TOKEN }}
```
### Inputs
| Name | Required | Description | Type | Default |
| -------------- | -------- | --------------------------------------- | ------ | ------- |
| `just-version` | no | A valid NPM-style semver specification. | string | * |
| Name | Required | Description | Type | Default |
| -------------- | -------- | --------------------------------------- | ------ | --------------------- |
| `just-version` | no | A valid NPM-style semver specification. | string | * |
| `github-token` | no | A Github token. | string | `${{ github.token }}` |
The semver specification is passed directly to NPM's [semver
package](https://www.npmjs.com/package/semver). This GitHub Action will install
+4
View File
@@ -7,6 +7,10 @@ branding:
inputs:
just-version:
description: 'A valid semver specifier of the just version to install'
github-token:
description: 'Github token to use to authenticate downloads'
required: false
default: ${{ github.token }}
runs:
using: 'node16'
main: 'dist/index.js'
+1 -1
View File
File diff suppressed because one or more lines are too long
+7 -7
View File
@@ -10,7 +10,7 @@
"license": "MIT OR Apache-2.0",
"dependencies": {
"@actions/core": "^1.9.1",
"@extractions/setup-crate": "^0.3.1"
"@extractions/setup-crate": "^0.4.0"
},
"devDependencies": {
"@types/node": "^18.7.21",
@@ -107,9 +107,9 @@
}
},
"node_modules/@extractions/setup-crate": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@extractions/setup-crate/-/setup-crate-0.3.1.tgz",
"integrity": "sha512-iudmGqmIKBVyFL2XlrcJA4VYUJLC/bL0W8FF3/fetPIsE9fMorckvVuPRt6nuHWTp687pIkZiNDbL7ttpzq6jA==",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@extractions/setup-crate/-/setup-crate-0.4.0.tgz",
"integrity": "sha512-Tip21gjBWwjO3kBDIIpfVVMGjGI4K31RwSMF5Z59NnbEmvQ86RkcHVrmku1ZFVn9UogobVSIzdmcUcb+IEX/JA==",
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/tool-cache": "^2.0.1",
@@ -1992,9 +1992,9 @@
}
},
"@extractions/setup-crate": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@extractions/setup-crate/-/setup-crate-0.3.1.tgz",
"integrity": "sha512-iudmGqmIKBVyFL2XlrcJA4VYUJLC/bL0W8FF3/fetPIsE9fMorckvVuPRt6nuHWTp687pIkZiNDbL7ttpzq6jA==",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@extractions/setup-crate/-/setup-crate-0.4.0.tgz",
"integrity": "sha512-Tip21gjBWwjO3kBDIIpfVVMGjGI4K31RwSMF5Z59NnbEmvQ86RkcHVrmku1ZFVn9UogobVSIzdmcUcb+IEX/JA==",
"requires": {
"@actions/core": "^1.9.1",
"@actions/tool-cache": "^2.0.1",
+1 -1
View File
@@ -21,7 +21,7 @@
"homepage": "https://github.com/extractions/setup-just#readme",
"dependencies": {
"@actions/core": "^1.9.1",
"@extractions/setup-crate": "^0.3.1"
"@extractions/setup-crate": "^0.4.0"
},
"devDependencies": {
"@types/node": "^18.7.21",
+11 -5
View File
@@ -3,12 +3,18 @@ import * as setup from "@extractions/setup-crate";
async function main() {
try {
const githubToken =
process.env.GITHUB_TOKEN || core.getInput("github-token");
const versionSpec = core.getInput("just-version");
const tool = await setup.checkOrInstallTool({
owner: "casey",
name: "just",
versionSpec,
});
const tool = await setup.checkOrInstallTool(
{
owner: "casey",
name: "just",
versionSpec,
},
{ auth: githubToken }
);
core.addPath(tool.dir);
core.info(`Successfully setup ${tool.name} v${tool.version}`);
} catch (err) {