Skip to content

Commit

Permalink
fix: proper raw.githubusercontent.com link
Browse files Browse the repository at this point in the history
  • Loading branch information
ChecksumDev committed Aug 31, 2023
1 parent 78654f8 commit 0e525e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
16 changes: 12 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { access, mkdir, writeFile } from 'fs/promises'

try {
const octokit = github.getOctokit(core.getInput('token'))
const versionsRepo = core.getInput('repo').split('/')
const requestedVersion = core.getInput('version')
const referencesPath = core.getInput('path')

const versionsRepo = core.getInput('repo').split('/')
const owner = versionsRepo[3]
const repo = versionsRepo[4]

const requestedVersion = core.getInput('version')
const refPath = core.getInput('path')

const res = await octokit.rest.repos.getContent({
owner,
repo,
Expand Down Expand Up @@ -42,7 +41,15 @@ try {
)

for (const version of versionList) {
const versionPath = `${refPath}/${version.split('/').slice(2).join('/')}` // Remove "versions/<version>" from the path
const versionPath = `${referencesPath}/${version
.split('/')
.slice(2)
.join('/')}`

const remoteVersionPath = `https://raw.githubusercontent.com/${owner}/${repo}/main/versions/${requestedVersion}/${version
.split('/')
.slice(2)
.join('/')}`

try {
await access(versionPath)
Expand All @@ -52,9 +59,8 @@ try {
/* empty */
}

const versionRes = await fetch(
`https://raw.githubusercontent.com/${owner}/${repo}/main/${versionPath}`
)
console.log(`Downloading ${remoteVersionPath}`)
const versionRes = await fetch(remoteVersionPath)

if (!versionRes.ok) {
throw new Error(
Expand Down

0 comments on commit 0e525e8

Please sign in to comment.