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.
| `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 }}`.
10
+
| `imageName` | ***Optional*** | The desired name for the image. Defaults to current repository name.
11
+
| `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)_.
12
+
| `buildArgs` | ***Optional*** | Any additional build arguments to use when building the image, separated by newline. _See [example below](#publishing-using-build-arguments)_.
13
+
| `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)_.
14
+
| `contextName` | ***Optional*** | What Dockerfile should GitHub Docker be using when building. Defaults to traditional `Dockerfile` name. _See [example below](#publishing-using-custom-context)_.
15
+
| `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)_.
8
16
9
-
**Required**. GitHub Token for the user. Must have write permissions for packages. Recommended set up would be to use the provided GitHub Token for your repository; `${{ secrets.GITHUB_TOKEN }}`.
|`imageURL`| The URL of the image, **without** the tag. |
12
22
13
-
*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.
23
+
## Example usage
14
24
15
-
###`username`
25
+
#### Simple, minimal usage...
16
26
17
-
*Optional*. GitHub user to publish the image on behalf of. Defaults to the user who triggered the action to run.
27
+
```yaml
28
+
- name: Publish Image
29
+
uses: matootie/github-docker:v3.0.0
30
+
with:
31
+
accessToken: ${{ github.token }}
32
+
```
18
33
19
-
### `repositoryName`
34
+
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!
20
35
21
-
*Optional*. The repository to push the image to. Defaults to current repository. Must be specified in format `user/repo`.
36
+
For additional customizations, see further examples below. For more information on the output URL, see [this example](#publishing-and-using-output).
22
37
23
-
### `imageName`
38
+
#### Publishing using custom tag...
39
+
40
+
```yaml
41
+
- name: Publish Image
42
+
uses: matootie/github-docker:v3.0.0
43
+
with:
44
+
accessToken: ${{ github.token }}
45
+
tag: latest
46
+
```
24
47
25
-
*Optional*. The desired name for the image. Defaults to current repository name.
48
+
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) for more details.
26
49
27
-
###`imageTag`
50
+
#### Publishing using several tags...
28
51
29
-
*Optional*. The desired tag for the image. Defaults to current branch or release version number.
52
+
```yaml
53
+
- name: Publish Image
54
+
uses: matootie/github-docker:v3.0.0
55
+
with:
56
+
accessToken: ${{ github.token }}
57
+
tag: |
58
+
latest
59
+
${{ github.sha }}
60
+
```
30
61
31
-
### `imageTagPrefix`
62
+
In this example we publish the same image under two different tags.
32
63
33
-
*Optional*. Added to the beginning of the tag. Useful if you want to let *GitHub Docker* decide the tag, but prepend something of your own to it.
64
+
#### Publishing using build arguments...
34
65
35
-
### `imageTagSuffix`
66
+
```yaml
67
+
- name: Publish Image
68
+
uses: matootie/github-docker:v3.0.0
69
+
with:
70
+
accessToken: ${{ github.token }}
71
+
buildArgs: |
72
+
ENVIRONMENT=test
73
+
SOME_OTHER_ARG=yes
74
+
```
36
75
37
-
*Optional*. Added to the end of the tag. Useful if you want to let *GitHub Docker* decide the tag, but append something of your own to it.
76
+
Using build arguments is easy, just set each one on its own individual line, similarly to how you would in a `.env` file.
38
77
39
-
###`buildArg`
78
+
#### Publishing and using output...
40
79
41
-
*Optional*. Any additional build arguments to use when building the image.
42
80
```yaml
43
-
with:
44
-
buildArg: |
45
-
HTTP_PROXY=http://10.20.30.2:1234
46
-
FTP_PROXY=http://40.50.60.5:4567
81
+
- name: Publish Image
82
+
uses: matootie/github-docker:v3.0.0
83
+
id: publish
84
+
with:
85
+
accessToken: ${{ github.token }}
86
+
87
+
- name: Print Image URL
88
+
run: echo ${{ steps.publish.outputs.imageURL }}
47
89
```
48
90
49
-
## Outputs
91
+
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.
54
106
55
-
## Simple usage
107
+
#### Publishing using custom context...
56
108
57
109
```yaml
58
-
- name: Checkout Repository
59
-
uses: actions/checkout@v2
60
110
- name: Publish Image
61
-
uses: matootie/github-docker@v2.2.2
111
+
uses: matootie/github-docker:v3.0.0
62
112
with:
63
-
accessToken: ${{ secrets.GITHUB_TOKEN }}
113
+
accessToken: ${{ github.token }}
114
+
context: custom/context/dir/
115
+
contextName: custom.Dockerfile
64
116
```
117
+
118
+
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.
119
+
120
+
#### Publishing to a different repository.
121
+
122
+
```yaml
123
+
- name: Publish Image
124
+
uses: matootie/github-docker:v3.0.0
125
+
with:
126
+
accessToken: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
127
+
repository: my-user/my-repo
128
+
```
129
+
130
+
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.
0 commit comments