Skip to content

Commit c5235a9

Browse files
committed
fix: I forgot to update the action.yml. This should fix a LOT of bugs.
1 parent b44e9e1 commit c5235a9

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This will clone the stripped Beat Saber references to the default path `./Refs`
1717

1818
| Name | Description | Required | Default |
1919
| ---------- | ---------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------- |
20-
| `token` | GitHub token for cloning the Beat Saber repository. | No | None |
20+
| `token` | GitHub token for cloning the Beat Saber repository. | No | `${{ github.token }}` |
2121
| `version` | Version of Beat Saber for the modding environment. If not specified, the action will try to infer it from a `manifest.json`. | No | None |
2222
| `manifest` | Path to a specific `manifest.json` file for version inference. If not provided, the action will search recursively. | No | None |
2323
| `path` | Path to clone the stripped Beat Saber references to. | No | `./Refs` |

action.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: "Initialize Beat Saber References"
2-
description: "A GitHub Action to initialize a stripped modding environment for use in GitHub Actions."
1+
name: "Initialize Beat Saber Development Environment"
2+
description: "A GitHub Action to initialize a Beat Saber modding environment"
33
author: "BeatForge"
44

55
branding:
@@ -11,17 +11,24 @@ inputs:
1111
description: "The GitHub token to use for downloading the modding environment"
1212
default: ${{ github.token }}
1313
required: false
14-
repo:
15-
description: "The version repository to use"
16-
default: "https://github.com/beat-forge/beatsaber-stripped"
17-
required: false
1814
version:
1915
description: "The BeatSaber version to use"
2016
required: true
17+
manifest:
18+
description: "The path to the manifest.json file to infer version if not specified"
19+
required: false
2120
path:
2221
description: "The location to install the modding environment to, defaults to ./Refs"
2322
required: false
2423
default: "./Refs"
24+
host:
25+
description: "The GitHub host to use, defaults to github.com"
26+
required: false
27+
default: "github.com"
28+
repo:
29+
description: "The repository to use (format: owner/repo)"
30+
default: "beat-forge/beatsaber-stripped"
31+
required: false
2532

2633
runs:
2734
using: node20

src/index.ts

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as core from '@actions/core'
22
import { promises as fs, createWriteStream } from 'fs'
33
import { dirname, join, resolve } from 'path'
4+
import { pipeline } from 'stream'
45
import * as tar from 'tar'
6+
import { promisify } from 'util'
57

6-
async function downloadFile(
7-
url: string,
8-
outputPath: string,
9-
token?: string
10-
): Promise<void> {
8+
const streamPipeline = promisify(pipeline)
9+
10+
async function downloadFile(url: string, outputPath: string, token?: string): Promise<void> {
1111
core.info(`Starting download from URL: ${url}`)
1212
const packageJson = require('../package.json')
1313
const userAgent = `beat-forge/init-beatsaber@${packageJson.version}`
@@ -36,24 +36,15 @@ async function downloadFile(
3636
core.debug(`Created directory for output path: ${dirname(outputPath)}`)
3737

3838
const fileStream = createWriteStream(outputPath)
39-
const reader = response.body?.getReader()
40-
41-
if (!reader) {
42-
core.error('Failed to get reader from response body')
43-
throw new Error('Failed to get reader from response body')
44-
}
4539

4640
core.info('Starting to read and write file stream')
47-
const pump = async () => {
48-
while (true) {
49-
const { done, value } = await reader.read()
50-
if (done) break
51-
if (value) fileStream.write(value)
52-
}
53-
fileStream.close()
41+
42+
if (response.body) {
43+
await streamPipeline(response.body, fileStream)
44+
} else {
45+
throw new Error('Response body is null')
5446
}
5547

56-
await pump()
5748
core.info('File downloaded and written successfully')
5849
}
5950

@@ -126,12 +117,12 @@ async function run(): Promise<void> {
126117
core.info('Initializing Beat Saber modding environment...')
127118

128119
const token = core.getInput('token')
129-
let requestedVersion = core.getInput('version')
130-
let manifestPath = core.getInput('manifest')
131-
let referencesPath = core.getInput('path') || './Refs'
120+
const repo = core.getInput('repo')
121+
const host = core.getInput('host')
132122

133-
let repo = core.getInput('repo') || 'beat-forge/beatsaber-stripped'
134-
let host = core.getInput('host') || 'github.com'
123+
const manifestPath = core.getInput('manifest')
124+
const referencesPath = core.getInput('path')
125+
let requestedVersion = core.getInput('version')
135126

136127
core.debug(
137128
`Inputs: version=${requestedVersion}, manifest=${manifestPath}, path=${referencesPath}, repo=${repo}, host=${host}`

0 commit comments

Comments
 (0)