diff --git a/__tests__/fs-helper.test.ts b/__tests__/fs-helper.test.ts index b86174a..68931ef 100644 --- a/__tests__/fs-helper.test.ts +++ b/__tests__/fs-helper.test.ts @@ -153,7 +153,7 @@ describe('isActionRepo', () => { expect(fsHelper.isActionRepo(stagingDir)).toEqual(true) }) - it('returns false if action.y(a)ml doesn\'t exist at the root', () => { + it("returns false if action.y(a)ml doesn't exist at the root", () => { fs.writeFileSync(path.join(stagingDir, `action.yaaml`), fileContent) expect(fsHelper.isActionRepo(stagingDir)).toEqual(false) }) diff --git a/dist/index.js b/dist/index.js index bed62a1..fb91e07 100644 --- a/dist/index.js +++ b/dist/index.js @@ -74693,7 +74693,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.bundleFilesintoDirectory = exports.readFileContents = exports.isDirectory = exports.createArchives = exports.removeDir = exports.createTempDir = void 0; +exports.bundleFilesintoDirectory = exports.readFileContents = exports.isActionRepo = exports.isDirectory = exports.createArchives = exports.removeDir = exports.createTempDir = void 0; const fs = __importStar(__nccwpck_require__(57147)); const fs_extra_1 = __importDefault(__nccwpck_require__(5630)); const path = __importStar(__nccwpck_require__(71017)); @@ -74764,6 +74764,11 @@ function isDirectory(dirPath) { return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory(); } exports.isDirectory = isDirectory; +function isActionRepo(stagingDir) { + return (fs.existsSync(path.join(stagingDir, 'action.yml')) || + fs.existsSync(path.join(stagingDir, 'action.yaml'))); +} +exports.isActionRepo = isActionRepo; function readFileContents(filePath) { return fs.readFileSync(filePath); } @@ -75052,17 +75057,11 @@ async function run(pathInput) { // https://docs.github.com/en/actions/creating-actions/releasing-and-maintaining-actions const targetVersion = semver_1.default.parse(releaseTag.replace(/^v/, '')); if (!targetVersion) { - // TODO: We may want to limit semvers to only x.x.x, without the pre-release tags, but for now we'll allow them. core.setFailed(`${releaseTag} is not a valid semantic version, and so cannot be uploaded as an Immutable Action.`); return; } const token = process.env.TOKEN; - // TODO: once https://github.com/github/github/pull/309384 goes in, we can switch to the actual endpoint - //const response = await fetch( - // process.env.GITHUB_API_URL + '/packages/container-registry-url' - //) - const response = await fetch('http://echo.jsontest.com/url/https:ghcr.io' // for testing locally. Remove the slashes, they will be reintroduced when forming the URL object below - ); + const response = await fetch(process.env.GITHUB_API_URL + '/packages/container-registry-url'); if (!response.ok) { throw new Error(`Failed to fetch status page: ${response.statusText}`); } @@ -75084,6 +75083,10 @@ async function run(pathInput) { tmpDirs.push(bundleDir); 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); diff --git a/src/fs-helper.ts b/src/fs-helper.ts index a191aba..5f81281 100644 --- a/src/fs-helper.ts +++ b/src/fs-helper.ts @@ -98,7 +98,6 @@ export function isActionRepo(stagingDir: string): boolean { ) } - export function readFileContents(filePath: string): Buffer { return fs.readFileSync(filePath) } @@ -124,7 +123,6 @@ 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 { const stats = fs.statSync(filePath)