You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 30, 2021. It is now read-only.
For help updating, view the [change logs](https://github.com/matootie/github-docker/releases).
7
+
For help updating, view the [change logs](https://github.com/matootie/github-docker/releases). If you need additional help feel free to submit an issue.
| `accessToken` | **Required** | GitHub Repository Token to log in using. Must have write permissions for packages. Recommended set up would be to use the provided GitHub Token for your repository; `${{ github.token }}`.
33
+
| `accessToken` | **Required** | GitHub Access Token to log in using. Must have write permissions for packages. Recommended set up would be to use the provided GitHub Token for your repository; `${{ github.token }}`.
14
34
| `imageName` | ***Optional*** | The desired name for the image. Defaults to current repository name.
15
35
| `tag` | ***Optional*** | The desired tag for the image. Defaults to `latest`. Optionally accepts multiple tags separated by newline. _See [example below](#publishing-using-several-tags)_.
16
36
| `buildArgs` | ***Optional*** | Any additional build arguments to use when building the image, separated by newline. _See [example below](#publishing-using-build-arguments)_.
17
37
| `context` | ***Optional*** | Where should GitHub Docker find the Dockerfile? This is a path relative to the repository root. Defaults to `.`, meaning it will look for a `Dockerfile` in the root of the repository. _See [example below](#publishing-using-custom-context)_.
18
38
| `contextName` | ***Optional*** | What Dockerfile should GitHub Docker be using when building. Defaults to traditional `Dockerfile` name. _See [example below](#publishing-using-custom-context)_.
39
+
| `containerRegistry` | ***Optional*** | Whether or not to push to GitHub Container Registry instead of GitHub Package Registry. _When using GitHub Container Registry there are a few important differences to keep in mind. See [explanation below](#github-container-registry-usage)_.
19
40
| `repository` | ***Optional*** | The repository to push the image to. Defaults to the current repository. Must be specified in format `user/repo`. _Note: Using an external repository requires elevated permissions. The provided GitHub token for the repository running the action will **not** suffice. You must use custom secret containing a [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) that has package write permissions on the given repository. See [example below](#publishing-to-a-different-repository)_.
20
41
21
42
## Outputs
@@ -24,26 +45,26 @@ For help updating, view the [change logs](https://github.com/matootie/github-doc
|`imageURL`| The URL of the image, **without** the tag. |
26
47
27
-
## Example usage
48
+
## GitHub Package Registry usage
28
49
29
50
#### Simple, minimal usage...
30
51
31
52
```yaml
32
53
- name: Publish Image
33
-
uses: matootie/github-docker@v3.0.0
54
+
uses: matootie/github-docker@v3.1.0
34
55
with:
35
56
accessToken: ${{ github.token }}
36
57
```
37
58
38
-
That's right this is all you need to get started with GitHub Docker, simply provide the GitHub token and the defaults will go to work. An image following the repository name will be pushed to the repository, with a tag corresponding to the commit SHA that triggered the workflow. The resulting URL is set as output for easy use in future steps!
59
+
That's right this is all you need to get started with GitHub Docker, simply provide the GitHub token and the defaults will go to work. An image following the repository name will be pushed to the repository, tagged with `latest`. The resulting URL is set as output for easy use in future steps!
39
60
40
61
For additional customizations, see further examples below. For more information on the output URL, see [this example](#publishing-and-using-output).
41
62
42
63
#### Publishing using custom tag...
43
64
44
65
```yaml
45
66
- name: Publish Image
46
-
uses: matootie/github-docker@v3.0.0
67
+
uses: matootie/github-docker@v3.1.0
47
68
with:
48
69
accessToken: ${{ github.token }}
49
70
tag: latest
@@ -55,7 +76,7 @@ In this example we specify a custom tag for the image. Remember to append the ta
55
76
56
77
```yaml
57
78
- name: Publish Image
58
-
uses: matootie/github-docker@v3.0.0
79
+
uses: matootie/github-docker@v3.1.0
59
80
with:
60
81
accessToken: ${{ github.token }}
61
82
tag: |
@@ -69,7 +90,7 @@ In this example we publish the same image under two different tags.
69
90
70
91
```yaml
71
92
- name: Publish Image
72
-
uses: matootie/github-docker@v3.0.0
93
+
uses: matootie/github-docker@v3.1.0
73
94
with:
74
95
accessToken: ${{ github.token }}
75
96
buildArgs: |
@@ -83,7 +104,7 @@ Using build arguments is easy, just set each one on its own individual line, sim
83
104
84
105
```yaml
85
106
- name: Publish Image
86
-
uses: matootie/github-docker@v3.0.0
107
+
uses: matootie/github-docker@v3.1.0
87
108
id: publish
88
109
with:
89
110
accessToken: ${{ github.token }}
@@ -96,7 +117,7 @@ In this example you can see how easy it is to reference the image URL after publ
96
117
97
118
```yaml
98
119
- name: Publish Image
99
-
uses: matootie/github-docker@v3.0.0
120
+
uses: matootie/github-docker@v3.1.0
100
121
id: publish
101
122
with:
102
123
accessToken: ${{ github.token }}
@@ -112,7 +133,7 @@ Otherwise, future steps will end up using the literal tag `latest` for the image
112
133
113
134
```yaml
114
135
- name: Publish Image
115
-
uses: matootie/github-docker@v3.0.0
136
+
uses: matootie/github-docker@v3.1.0
116
137
with:
117
138
accessToken: ${{ github.token }}
118
139
context: custom/context/dir/
@@ -125,10 +146,121 @@ Here we see an example where GitHub Docker is given additional context on how to
125
146
126
147
```yaml
127
148
- name: Publish Image
128
-
uses: matootie/github-docker@v3.0.0
149
+
uses: matootie/github-docker@v3.1.0
129
150
with:
130
151
accessToken: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
131
152
repository: my-user/my-repo
132
153
```
133
154
134
155
In this example we're pushing the resulting image to be listed under a separate repository, different from the one that this action is running on. Remember, in this case the provided `${{ github.token }}` will **not** work as it only has the necessary permissions for its own repository. You need to save a GitHub [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with write permissions to packages as a secret, and use that.
156
+
157
+
## GitHub Container Registry usage
158
+
159
+
Using GitHub Docker with the GitHub Container Registry is just about the same as using it with the Package Registry, but there are a few things to remember.
160
+
161
+
1. The `accessToken` input must be a [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with `write:packages` scope.
162
+
2. The `repositoryName` input is entirely useless as the container will be pushed to the owner of the current repository instead.
163
+
164
+
The following are a copy of the same examples listed above, using GitHub Container Registry instead of GitHub Package Registry. _Note the differences in input_.
165
+
166
+
#### Simple, minimal usage...
167
+
168
+
```yaml
169
+
- name: Publish Image
170
+
uses: matootie/github-docker@v3.1.0
171
+
with:
172
+
accessToken: ${{ secrets.PAT }}
173
+
containerRegistry: true
174
+
```
175
+
176
+
That's right this is all you need to get started with GitHub Docker, simply provide the GitHub token and the defaults will go to work. An image following the repository name will be pushed to the repository owner, tagged with `latest`. The resulting URL is set as output for easy use in future steps!
177
+
178
+
For additional customizations, see further examples below. For more information on the output URL, see [this example](#publishing-and-using-output-1).
179
+
180
+
#### Publishing using custom tag...
181
+
182
+
```yaml
183
+
- name: Publish Image
184
+
uses: matootie/github-docker@v3.1.0
185
+
with:
186
+
accessToken: ${{ secrets.PAT }}
187
+
tag: latest
188
+
containerRegistry: true
189
+
```
190
+
191
+
In this example we specify a custom tag for the image. Remember to append the tag when using the outputted image URL in the workflow. See [this example](#publishing-and-using-output-1) for more details.
192
+
193
+
#### Publishing using several tags...
194
+
195
+
```yaml
196
+
- name: Publish Image
197
+
uses: matootie/github-docker@v3.1.0
198
+
with:
199
+
accessToken: ${{ secrets.PAT }}
200
+
tag: |
201
+
latest
202
+
${{ github.sha }}
203
+
containerRegistry: true
204
+
```
205
+
206
+
In this example we publish the same image under two different tags.
207
+
208
+
#### Publishing using build arguments...
209
+
210
+
```yaml
211
+
- name: Publish Image
212
+
uses: matootie/github-docker@v3.1.0
213
+
with:
214
+
accessToken: ${{ secrets.PAT }}
215
+
buildArgs: |
216
+
ENVIRONMENT=test
217
+
SOME_OTHER_ARG=yes
218
+
containerRegistry: true
219
+
```
220
+
221
+
Using build arguments is easy, just set each one on its own individual line, similarly to how you would in a `.env` file.
222
+
223
+
#### Publishing and using output...
224
+
225
+
```yaml
226
+
- name: Publish Image
227
+
uses: matootie/github-docker@v3.1.0
228
+
id: publish
229
+
with:
230
+
accessToken: ${{ secrets.PAT }}
231
+
containerRegistry: true
232
+
233
+
- name: Print Image URL
234
+
run: echo ${{ steps.publish.outputs.imageURL }}
235
+
```
236
+
237
+
In this example you can see how easy it is to reference the image URL after publishing. If you are using a custom tag, you most likely are going to need to append the tag to the URL when using it in the workflow...
Otherwise, future steps will end up using the literal tag `latest` for the image and not the customized tag.
253
+
254
+
#### Publishing using custom context...
255
+
256
+
```yaml
257
+
- name: Publish Image
258
+
uses: matootie/github-docker@v3.1.0
259
+
with:
260
+
accessToken: ${{ secrets.PAT }}
261
+
context: custom/context/dir/
262
+
contextName: custom.Dockerfile
263
+
containerRegistry: true
264
+
```
265
+
266
+
Here we see an example where GitHub Docker is given additional context on how to find the right Dockerfile. `context` is used to specify the directory of the Dockerfile, and `contextName` is used if the name of the Dockerfile is something that different than what `docker build .` would find.
0 commit comments