From fade7a72bc2f9e12fa1101ecdb597f4e0136dbf2 Mon Sep 17 00:00:00 2001 From: Elias <46247153+EliasVal@users.noreply.github.com> Date: Sat, 19 Aug 2023 00:37:38 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20the=20option=20to=20specify?= =?UTF-8?q?=20the=20destination=20path=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++------ action.yml | 3 +++ src/extract.js | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bc77587..beefa40 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,11 @@ A GitHub Action for extracting files from a Docker Image. ## Inputs -All inputs are required. - -| ID | Description | Examples | -| ------- | ---------------------------------------------------- | --------------------------------------------- | -| `image` | Docker Image to extract files from | `alpine` `ghcr.io/github/super-linter:latest` | -| `path` | Path (from root) to a file or directory within Image | `files/example.txt` `files` `files/.` | +| ID | Description | Required | Examples | +| ------------- | ---------------------------------------------------- | :------: | --------------------------------------------- | +| `image` | Docker Image to extract files from | ✅ | `alpine` `ghcr.io/github/super-linter:latest` | +| `path` | Path (from root) to a file or directory within Image | ✅ | `files/example.txt` `files` `files/.` | +| `destination` | Destination path for the extracted files | ❌ | `/foo/` `~/` `./foo/bar` | > :paperclip: To copy the **contents** of a directory the `path` must end with > `/.` otherwise the directory itself will be copied. More information about the diff --git a/action.yml b/action.yml index 228dd3b..68fda5e 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: path: description: 'Path (from root) to a file or directory within Image' required: true + destination: + description: 'Destination path for the extracted files' + required: false outputs: destination: description: 'Destination of extracted file(s)' diff --git a/src/extract.js b/src/extract.js index 28ab202..9c0e32d 100644 --- a/src/extract.js +++ b/src/extract.js @@ -5,7 +5,8 @@ async function run() { try { const image = core.getInput('image'); const path = core.getInput('path'); - const destination = `.extracted-${Date.now()}`; + const destination = core.getInput('destination') || `.extracted-${Date.now()}`; + const create = `docker cp $(docker create ${image}):/${path} ${destination}`; await exec.exec(`mkdir -p ${destination}`);