-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.md
111 lines (92 loc) · 3.92 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Docker Extract
A GitHub Action for extracting files from a Docker Image.
```yaml
- uses: shrink/actions-docker-extract@v3
with:
image: "ghost:alpine"
path: "/var/lib/ghost/current/core/built/assets/."
```
## Inputs
| 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
> specific rules can be found via the [docker cp][docker-cp] documentation.
## Outputs
| ID | Description | Example |
| ------------- | ------------------------------------------------- | ------------------------ |
| `destination` | Destination path containing the extracted file(s) | `.extracted-1598717412/` |
## 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@v4
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
repository: my-example-image
tags: latest
- uses: shrink/actions-docker-extract@v3
id: extract
with:
image: my-example-image
path: /app/.
- name: Upload Dist
uses: actions/upload-artifact@v3
with:
path: ${{ steps.extract.outputs.destination }}
name: dist
```
### Login, Pull, Extract
Using [docker/login-action][login-action] to authenticate with the GitHub
Container Registry to extract from a published Docker Image.
```yaml
jobs:
extract:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}
- uses: shrink/actions-docker-extract@v3
id: extract
with:
image: ghcr.io/${{ github.repository }}:latest
path: /app/.
- name: Upload Dist
uses: actions/upload-artifact@v3
with:
path: ${{ steps.extract.outputs.destination }}
name: dist
```
## Automatic Release Packaging
A Workflow packages the Action automatically when a collaborator created a new
tag. Any reference to this Action in a Workflow must use a [tag][tags] (mutable)
or the commit hash of a tag (immutable).
```yaml
✅ uses: shrink/actions-docker-extract@v3
✅ uses: shrink/actions-docker-extract@v3.0.0
✅ uses: shrink/actions-docker-extract@40400b42f4f8b663c647f535e2c6674658e39fc6
❌ uses: shrink/actions-docker-extract@main
```
The blog post
[Package GitHub Actions automatically with GitHub Actions][blog/package-automatically]
describes how this is achieved.
[build-push-action]: https://github.com/docker/build-push-action
[login-action]: https://github.com/docker/login-action
[docker-cp]: https://docs.docker.com/engine/reference/commandline/cp/#extended-description
[tags]: https://github.com/shrink/actions-docker-extract/tags
[blog/package-automatically]: https://medium.com/prompt/package-github-actions-automatically-with-github-actions-a70b9f7bae4