fix filepath when using path input

This commit is contained in:
Peter Evans 2024-07-27 21:02:41 +00:00
parent 396429353a
commit 184d576617
3 changed files with 10 additions and 4 deletions

View file

@ -1,5 +1,4 @@
import * as core from '@actions/core'
import * as fs from 'fs'
import {graphql} from '@octokit/graphql'
import type {
Repository,
@ -327,7 +326,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
core.debug(`Reading contents of file: '${file}'`)
fileChanges.additions!.push({
path: file,
contents: fs.readFileSync(file).toString('base64')
contents: utils.readFileBase64([repoPath, file])
})
}

View file

@ -126,6 +126,10 @@ export function readFile(path: string): string {
return fs.readFileSync(path, 'utf-8')
}
export function readFileBase64(pathParts: string[]): string {
return fs.readFileSync(path.resolve(...pathParts)).toString('base64')
}
/* eslint-disable @typescript-eslint/no-explicit-any */
function hasErrorCode(error: any): error is {code: string} {
return typeof (error && error.code) === 'string'