Require to specify GITHUB_TOKEN for considering API limit

This commit is contained in:
Kenichi Kamiya 2023-02-23 02:58:25 +09:00
parent 90cd64f028
commit 0410c15177
5 changed files with 25 additions and 50 deletions

View file

@ -33,6 +33,8 @@ jobs:
- uses: ./
with:
tool_versions: ${{ matrix.tool_versions }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: rtx --version
- run: rtx exec -- node --version
- run: which node

View file

@ -19,12 +19,16 @@ jobs:
with:
tool_versions: |
shellcheck 0.9.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: shellcheck scripts/*.sh
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jdxcode/rtx-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# .tool-versions will be read from repo root
- run: node ./my_app.js
```

27
dist/index.js generated vendored
View file

@ -55,29 +55,20 @@ function 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() {
return __awaiter(this, void 0, void 0, function* () {
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin');
const platform = `${getOS()}-${os.arch()}`;
yield fs.promises.mkdir(rtxBinDir, { recursive: true });
yield exec.exec('curl', [
'-sSfL',
'--compressed',
yield exec.exec('gh', [
'release',
'download',
'--pattern',
`*${platform}`,
'--repo',
'jdxcode/rtx',
'--output',
path.join(rtxBinDir, 'rtx'),
yield getLatestRTXAssetURL()
path.join(rtxBinDir, 'rtx')
]);
yield exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
core.addPath(rtxBinDir);

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -12,41 +12,19 @@ async function run(): Promise<void> {
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> {
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin')
const platform = `${getOS()}-${os.arch()}`
await fs.promises.mkdir(rtxBinDir, {recursive: true})
await exec.exec('curl', [
'-sSfL',
'--compressed',
await exec.exec('gh', [
'release',
'download',
'--pattern',
`*${platform}`,
'--repo',
'jdxcode/rtx',
'--output',
path.join(rtxBinDir, 'rtx'),
await getLatestRTXAssetURL()
path.join(rtxBinDir, 'rtx')
])
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
core.addPath(rtxBinDir)