isActionRepo()

This commit is contained in:
Edwin Sirko
2024-01-26 13:07:57 -05:00
parent 55e582b23e
commit 4ed2e10e92
3 changed files with 44 additions and 0 deletions
+9
View File
@@ -91,6 +91,14 @@ export function isDirectory(dirPath: string): boolean {
return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory()
}
export function isActionRepo(stagingDir: string): boolean {
return (
fs.existsSync(path.join(stagingDir, 'action.yml')) ||
fs.existsSync(path.join(stagingDir, 'action.yaml'))
)
}
export function readFileContents(filePath: string): Buffer {
return fs.readFileSync(filePath)
}
@@ -116,6 +124,7 @@ export function bundleFilesintoDirectory(
return targetDir
}
// Converts a file path to a filemetadata object by querying the fs for relevant metadata.
async function fileMetadata(filePath: string): Promise<FileMetadata> {
const stats = fs.statSync(filePath)
+7
View File
@@ -65,6 +65,13 @@ export async function run(pathInput: string): Promise<void> {
path = fsHelper.bundleFilesintoDirectory(paths, bundleDir)
}
if (!fsHelper.isActionRepo(path)) {
core.setFailed(
'action.y(a)ml not found. Action packages can be created only for action repositories.'
)
return
}
// Create a temporary directory to store the archives
const archiveDir = fsHelper.createTempDir()
tmpDirs.push(archiveDir)