mirror of
https://forgejo.merr.is/annika/actions-docker-extract.git
synced 2025-12-11 12:02:05 -05:00
✨ Add the option to specify the destination path (#20)
This commit is contained in:
parent
fa24b0e3ce
commit
fade7a72bc
3 changed files with 10 additions and 7 deletions
11
README.md
11
README.md
|
|
@ -11,12 +11,11 @@ A GitHub Action for extracting files from a Docker Image.
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
All inputs are required.
|
| ID | Description | Required | Examples |
|
||||||
|
| ------------- | ---------------------------------------------------- | :------: | --------------------------------------------- |
|
||||||
| 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/.` |
|
||||||
| `image` | Docker Image to extract files from | `alpine` `ghcr.io/github/super-linter:latest` |
|
| `destination` | Destination path for the extracted files | ❌ | `/foo/` `~/` `./foo/bar` |
|
||||||
| `path` | Path (from root) to a file or directory within Image | `files/example.txt` `files` `files/.` |
|
|
||||||
|
|
||||||
> :paperclip: To copy the **contents** of a directory the `path` must end with
|
> :paperclip: To copy the **contents** of a directory the `path` must end with
|
||||||
> `/.` otherwise the directory itself will be copied. More information about the
|
> `/.` otherwise the directory itself will be copied. More information about the
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ inputs:
|
||||||
path:
|
path:
|
||||||
description: 'Path (from root) to a file or directory within Image'
|
description: 'Path (from root) to a file or directory within Image'
|
||||||
required: true
|
required: true
|
||||||
|
destination:
|
||||||
|
description: 'Destination path for the extracted files'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
destination:
|
destination:
|
||||||
description: 'Destination of extracted file(s)'
|
description: 'Destination of extracted file(s)'
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ async function run() {
|
||||||
try {
|
try {
|
||||||
const image = core.getInput('image');
|
const image = core.getInput('image');
|
||||||
const path = core.getInput('path');
|
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}`;
|
const create = `docker cp $(docker create ${image}):/${path} ${destination}`;
|
||||||
|
|
||||||
await exec.exec(`mkdir -p ${destination}`);
|
await exec.exec(`mkdir -p ${destination}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue