From 3163ab47f5092df69ad6e2ccd055bb3e9164d2a8 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 23 Nov 2021 01:40:20 -0300 Subject: [PATCH] Don't modify original Flatpak manifest Store the modified manifest in another JSON or YML file in the same folder of the original file, but prefixed with 'flatpak-github-action-modified-'. Fixes https://github.com/bilelmoussaoui/flatpak-github-actions/issues/61 --- flatpak-builder/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/flatpak-builder/index.js b/flatpak-builder/index.js index 4e8f7bfd..d351eecb 100644 --- a/flatpak-builder/index.js +++ b/flatpak-builder/index.js @@ -113,6 +113,19 @@ const modifyManifest = (manifest, runTests = false) => { return manifest } +/** + * Gets the modified manifest as a YAML or JSON file + * + * @param {PathLike} manifestPath Where to save the flatpak manifest + * @returns {PathLike} the manifest + */ +const getModifiedManifestPath = manifestPath => { + return path.join( + path.dirname(manifestPath), + `flatpak-github-action-modified-${path.basename(manifestPath)}` + ) +} + /** * Build the flatpak & create a bundle from the build * @@ -244,13 +257,14 @@ const run = async ( core.setFailed(`Failed to prepare the build ${err}`) } + const modifiedManifestPath = getModifiedManifestPath(manifestPath) parseManifest(manifestPath) .then((manifest) => { const modifiedManifest = modifyManifest(manifest, runTests) - return saveManifest(modifiedManifest, manifestPath) + return saveManifest(modifiedManifest, modifiedManifestPath) }) .then((manifest) => { - return build(manifest, manifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch) + return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch) }) .then(() => { core.info('Uploading artifact...')