diff --git a/.github/workflows/download.yml b/.github/workflows/download.yml index 8da78cc4..4898f9d8 100644 --- a/.github/workflows/download.yml +++ b/.github/workflows/download.yml @@ -103,9 +103,10 @@ jobs: skip_unpack: true - name: Test run: | - test -f artifact.zip - ! test -d artifact - unzip -l artifact.zip + test -d artifact + test -f artifact/artifact.zip + ! test -f artifact.zip + unzip -l artifact/artifact.zip download-dry-run-exists: runs-on: ubuntu-latest needs: wait diff --git a/main.js b/main.js index f6ceb92d..280abb2b 100644 --- a/main.js +++ b/main.js @@ -36,6 +36,22 @@ async function main() { core.info(`==> Repository: ${owner}/${repo}`) core.info(`==> Workflow conclusion: ${workflowConclusion}`) + const uniqueInputSets = [ + { + "pr": pr, + "commit": commit, + "branch": branch, + "run_id": runID + } + ] + uniqueInputSets.forEach((inputSet) => { + const inputs = Object.values(inputSet) + const providedInputs = inputs.filter(input => input !== '') + if (providedInputs.length > 1) { + throw new Error(`The following inputs cannot be used together: ${Object.keys(inputSet).join(", ")}`) + } + }) + if (pr) { core.info(`==> PR: ${pr}`) const pull = await client.pulls.get({ @@ -174,15 +190,14 @@ async function main() { archive_format: "zip", }) + const dir = name ? path : pathname.join(path, artifact.name) + fs.mkdirSync(dir, { recursive: true }) + if (skipUnpack) { - fs.writeFileSync(`${artifact.name}.zip`, Buffer.from(zip.data), 'binary') + fs.writeFileSync(`${pathname.join(path, artifact.name)}.zip`, Buffer.from(zip.data), 'binary') continue } - const dir = name ? path : pathname.join(path, artifact.name) - - fs.mkdirSync(dir, { recursive: true }) - const adm = new AdmZip(Buffer.from(zip.data)) core.startGroup(`==> Extracting: ${artifact.name}.zip`)