Require to specify GITHUB_TOKEN for considering API limit
This commit is contained in:
parent
90cd64f028
commit
0410c15177
5 changed files with 25 additions and 50 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -33,6 +33,8 @@ jobs:
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
tool_versions: ${{ matrix.tool_versions }}
|
tool_versions: ${{ matrix.tool_versions }}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: rtx --version
|
- run: rtx --version
|
||||||
- run: rtx exec -- node --version
|
- run: rtx exec -- node --version
|
||||||
- run: which node
|
- run: which node
|
||||||
|
|
|
@ -19,12 +19,16 @@ jobs:
|
||||||
with:
|
with:
|
||||||
tool_versions: |
|
tool_versions: |
|
||||||
shellcheck 0.9.0
|
shellcheck 0.9.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: shellcheck scripts/*.sh
|
- run: shellcheck scripts/*.sh
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: jdxcode/rtx-action@v1
|
- uses: jdxcode/rtx-action@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# .tool-versions will be read from repo root
|
# .tool-versions will be read from repo root
|
||||||
- run: node ./my_app.js
|
- run: node ./my_app.js
|
||||||
```
|
```
|
||||||
|
|
27
dist/index.js
generated
vendored
27
dist/index.js
generated
vendored
|
@ -55,29 +55,20 @@ function run() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
function getLatestRTXAssetURL() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const output = yield exec.getExecOutput('curl', ['-sSf', 'https://api.github.com/repos/jdxcode/rtx/releases/latest'], { silent: true });
|
|
||||||
const json = JSON.parse(output.stdout);
|
|
||||||
const platform = `${getOS()}-${os.arch()}`;
|
|
||||||
const asset = json.assets.find(a => a.name.endsWith(platform));
|
|
||||||
if (!asset) {
|
|
||||||
const assets = json.assets.map(a => a.name).join(', ');
|
|
||||||
throw new Error(`No asset for ${platform}, got: ${assets}`);
|
|
||||||
}
|
|
||||||
return asset.browser_download_url;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function setupRTX() {
|
function setupRTX() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin');
|
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin');
|
||||||
|
const platform = `${getOS()}-${os.arch()}`;
|
||||||
yield fs.promises.mkdir(rtxBinDir, { recursive: true });
|
yield fs.promises.mkdir(rtxBinDir, { recursive: true });
|
||||||
yield exec.exec('curl', [
|
yield exec.exec('gh', [
|
||||||
'-sSfL',
|
'release',
|
||||||
'--compressed',
|
'download',
|
||||||
|
'--pattern',
|
||||||
|
`*${platform}`,
|
||||||
|
'--repo',
|
||||||
|
'jdxcode/rtx',
|
||||||
'--output',
|
'--output',
|
||||||
path.join(rtxBinDir, 'rtx'),
|
path.join(rtxBinDir, 'rtx')
|
||||||
yield getLatestRTXAssetURL()
|
|
||||||
]);
|
]);
|
||||||
yield exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
|
yield exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
|
||||||
core.addPath(rtxBinDir);
|
core.addPath(rtxBinDir);
|
||||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
40
src/main.ts
40
src/main.ts
|
@ -12,41 +12,19 @@ async function run(): Promise<void> {
|
||||||
await setPaths()
|
await setPaths()
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GHAsset {
|
|
||||||
name: string
|
|
||||||
url: string
|
|
||||||
browser_download_url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GHAssets {
|
|
||||||
assets: GHAsset[]
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getLatestRTXAssetURL(): Promise<string> {
|
|
||||||
const output = await exec.getExecOutput(
|
|
||||||
'curl',
|
|
||||||
['-sSf', 'https://api.github.com/repos/jdxcode/rtx/releases/latest'],
|
|
||||||
{silent: true}
|
|
||||||
)
|
|
||||||
const json: GHAssets = JSON.parse(output.stdout)
|
|
||||||
const platform = `${getOS()}-${os.arch()}`
|
|
||||||
const asset = json.assets.find(a => a.name.endsWith(platform))
|
|
||||||
if (!asset) {
|
|
||||||
const assets = json.assets.map(a => a.name).join(', ')
|
|
||||||
throw new Error(`No asset for ${platform}, got: ${assets}`)
|
|
||||||
}
|
|
||||||
return asset.browser_download_url
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setupRTX(): Promise<void> {
|
async function setupRTX(): Promise<void> {
|
||||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin')
|
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin')
|
||||||
|
const platform = `${getOS()}-${os.arch()}`
|
||||||
await fs.promises.mkdir(rtxBinDir, {recursive: true})
|
await fs.promises.mkdir(rtxBinDir, {recursive: true})
|
||||||
await exec.exec('curl', [
|
await exec.exec('gh', [
|
||||||
'-sSfL',
|
'release',
|
||||||
'--compressed',
|
'download',
|
||||||
|
'--pattern',
|
||||||
|
`*${platform}`,
|
||||||
|
'--repo',
|
||||||
|
'jdxcode/rtx',
|
||||||
'--output',
|
'--output',
|
||||||
path.join(rtxBinDir, 'rtx'),
|
path.join(rtxBinDir, 'rtx')
|
||||||
await getLatestRTXAssetURL()
|
|
||||||
])
|
])
|
||||||
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
|
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
|
||||||
core.addPath(rtxBinDir)
|
core.addPath(rtxBinDir)
|
||||||
|
|
Loading…
Add table
Reference in a new issue