2020-08-29 16:20:01 +01:00
|
|
|
# Docker Extract
|
|
|
|
|
|
|
|
|
|
A GitHub Action for extracting files from a Docker Image.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
- uses: shrink/actions-docker-extract@v1
|
|
|
|
|
with:
|
2020-09-06 18:47:06 +01:00
|
|
|
image: 'ghost:alpine'
|
|
|
|
|
path: '/var/lib/ghost/current/core/built/assets/.'
|
2020-08-29 16:20:01 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Inputs
|
|
|
|
|
|
|
|
|
|
All inputs are required.
|
|
|
|
|
|
2020-09-06 18:47:06 +01:00
|
|
|
| ID | Description | Examples |
|
|
|
|
|
| --- | ----------- | -------- |
|
2020-11-15 22:34:27 +00:00
|
|
|
| `image` | Docker Image to extract files from | `alpine` `ghcr.io/github/super-linter:latest` |
|
2020-09-06 18:47:06 +01:00
|
|
|
| `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
|
|
|
|
|
`/.` otherwise the directory itself will be copied. More information about the
|
|
|
|
|
specific rules can be found via the [docker cp][docker-cp] documentation.
|
2020-08-29 16:20:01 +01:00
|
|
|
|
2020-08-29 18:07:22 +01:00
|
|
|
## Outputs
|
|
|
|
|
|
|
|
|
|
| ID | Description | Example |
|
|
|
|
|
| --- | ----------- | ------- |
|
2020-09-06 18:47:06 +01:00
|
|
|
| `destination` | Destination path containing the extracted file(s) | `.extracted-1598717412/` |
|
2020-08-29 18:07:22 +01:00
|
|
|
|
2020-08-29 16:20:01 +01:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
### Build, Extract
|
|
|
|
|
|
|
|
|
|
Using [docker/build-push-action][build-push-action] to build a Docker
|
|
|
|
|
Image and then extract the contents of the `/app` directory within the newly
|
|
|
|
|
built image to upload as a `dist` artifact.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
- name: Build Docker Image
|
|
|
|
|
uses: docker/build-push-action@v1
|
|
|
|
|
with:
|
|
|
|
|
repository: my-example-image
|
|
|
|
|
tags: latest
|
|
|
|
|
- uses: shrink/actions-docker-extract@v1
|
|
|
|
|
with:
|
|
|
|
|
image: my-example-image
|
2020-09-06 18:47:06 +01:00
|
|
|
path: /app/.
|
2020-08-29 16:20:01 +01:00
|
|
|
- name: Upload Dist
|
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
|
with:
|
2020-09-06 15:57:37 +01:00
|
|
|
path: ${{ steps.extract.outputs.destination }}
|
2020-08-29 16:20:01 +01:00
|
|
|
name: dist
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Login, Pull, Extract
|
|
|
|
|
|
|
|
|
|
Using [docker/login-action][login-action] to authenticate with the GitHub
|
2020-11-15 22:34:27 +00:00
|
|
|
Container Registry to extract from a published Docker Image.
|
2020-08-29 16:20:01 +01:00
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
jobs:
|
|
|
|
|
extract:
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v2
|
2020-11-15 22:34:27 +00:00
|
|
|
- name: Login to GitHub Container Registry
|
2020-08-29 16:20:01 +01:00
|
|
|
uses: docker/login-action@v1
|
|
|
|
|
with:
|
2020-11-15 22:34:27 +00:00
|
|
|
registry: ghcr.io
|
2020-08-29 16:20:01 +01:00
|
|
|
username: ${{ github.repository_owner }}
|
2020-11-15 22:34:27 +00:00
|
|
|
password: ${{ secrets.GHCR_PAT }}
|
2020-08-29 16:20:01 +01:00
|
|
|
- uses: shrink/actions-docker-extract@v1
|
|
|
|
|
with:
|
2020-11-15 22:34:27 +00:00
|
|
|
image: ghcr.io/${{ github.repository }}:latest
|
2020-09-06 18:47:06 +01:00
|
|
|
path: /app/.
|
2020-08-29 16:20:01 +01:00
|
|
|
- name: Upload Dist
|
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
|
with:
|
2020-09-06 15:57:37 +01:00
|
|
|
path: ${{ steps.extract.outputs.destination }}
|
2020-08-29 16:20:01 +01:00
|
|
|
name: dist
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
[build-push-action]: https://github.com/docker/build-push-action
|
|
|
|
|
[login-action]: https://github.com/docker/login-action
|
2020-09-06 18:47:06 +01:00
|
|
|
[docker-cp]: https://docs.docker.com/engine/reference/commandline/cp/#extended-description
|