Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit 6467451

Browse files
matootieayalaluquezayalaluquez
authored
Adjust and merge new features into master (#19)
* Updates from forked repository (#18) * Adjusting new features .eslintrc.json | 17 - .github/CODEOWNERS | 1 + .github/FUNDING.yml | 1 + .github/workflows/CI.yml | 69 +-- .github/workflows/README.md | 10 - CODEOWNERS | 2 - README.md | 147 +++-- action.yml | 38 +- dist/index.js | 120 ++--- index.js | 110 ++-- package-lock.json | 1018 +---------------------------------- package.json | 15 +- test/Dockerfile | 14 - test/Dockerfile.test | 14 - test/test.Dockerfile | 9 + 15 files changed, 234 insertions(+), 1351 deletions(-) * Fix path issue and broken link in README README.md | 4 +++- index.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) * Update dist/index.js dist/index.js | 1 + 1 file changed, 1 insertion(+) * Fix issue with contextName .github/workflows/CI.yml | 4 ++-- dist/index.js | 4 +++- index.js | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) * Remove macOS from build matrix It doesn't have Docker installed by default, and installing for specifically macOS runners is useless at the moment. .github/workflows/CI.yml | 1 - 1 file changed, 1 deletion(-) * Update testing image to use Windows compatible base .github/workflows/CI.yml | 5 ----- test/test.Dockerfile | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) * Remove Windows from build matrix .github/workflows/CI.yml | 2 -- 1 file changed, 2 deletions(-) * Add Changelog.md Co-authored-by: ayalaluquez <blanca.ayala@kronoscode.com> Co-authored-by: Blanca Ayala <45976038+ayalaluquez@users.noreply.github.com>
1 parent 3388e8a commit 6467451

14 files changed

Lines changed: 247 additions & 1271 deletions

File tree

.eslintrc.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @matootie

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: [matootie, 123FLO321]
1+
github: matootie

.github/workflows/CI.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "GitHub Docker"
2+
on:
3+
push:
4+
paths:
5+
- ".github/workflows/CI.yml"
6+
- "dist/index.js"
7+
jobs:
8+
test:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os:
13+
- ubuntu-16.04
14+
- ubuntu-18.04
15+
- ubuntu-20.04
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
20+
- name: Run the action
21+
uses: ./
22+
id: publish
23+
with:
24+
accessToken: ${{ github.token }}
25+
imageName: action-test
26+
tag: |
27+
latest-${{ matrix.os }}
28+
test-${{ matrix.os }}
29+
buildArgs: |
30+
TESTARG1=test1
31+
TESTARG2=test2
32+
context: test/
33+
contextName: test.Dockerfile

.github/workflows/test.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
### v3.0.0
4+
5+
* `contextName` can now be specified for GitHub Docker to find Dockerfiles with custom names.
6+
* Removed `username` input.
7+
* Renamed `repositoryName` to just `repository`.
8+
* Replaced `imageTag` with `tag`. Multiple tags can be specified via newline.
9+
* Tag now defaults to `latest`, as appose to commit SHA.
10+
* Removed `imageTagPrefix` and `imageTagSuffix` inputs.

README.md

Lines changed: 96 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,127 @@ Build and publish your repository as a Docker image and push it to GitHub Packag
44

55
## Inputs
66

7-
### `accessToken`
7+
| Name | Requirement | Description |
8+
| --------------------- | ----------------- | ------------|
9+
| `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)_.
816

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 }}`.
17+
## Outputs
1018

11-
### `context`
19+
| With Parameter | Description |
20+
| --------------------- | ------------------------------------------ |
21+
| `imageURL` | The URL of the image, **without** the tag. |
1222

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
1424

15-
### `username`
25+
#### Simple, minimal usage...
1626

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+
```
1833
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!
2035
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).
2237
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+
```
2447
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.
2649
27-
### `imageTag`
50+
#### Publishing using several tags...
2851
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+
```
3061
31-
### `imageTagPrefix`
62+
In this example we publish the same image under two different tags.
3263
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...
3465
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+
```
3675
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.
3877

39-
### `buildArg`
78+
#### Publishing and using output...
4079

41-
*Optional*. Any additional build arguments to use when building the image.
4280
```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 }}
4789
```
4890

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...
5092

51-
### `imageURL`
93+
```yaml
94+
- name: Publish Image
95+
uses: matootie/github-docker:v3.0.0
96+
id: publish
97+
with:
98+
accessToken: ${{ github.token }}
99+
tag: ${{ github.sha }}
100+
101+
- name: Print Full Image URL
102+
run: echo ${{ stets.publish.outputs.imageURL }}/${{ github.sha }}
103+
```
52104

53-
The full URL of the image.
105+
Otherwise, future steps will end up using the literal tag `latest` for the image and not the customized tag.
54106

55-
## Simple usage
107+
#### Publishing using custom context...
56108

57109
```yaml
58-
- name: Checkout Repository
59-
uses: actions/checkout@v2
60110
- name: Publish Image
61-
uses: matootie/github-docker@v2.2.2
111+
uses: matootie/github-docker:v3.0.0
62112
with:
63-
accessToken: ${{ secrets.GITHUB_TOKEN }}
113+
accessToken: ${{ github.token }}
114+
context: custom/context/dir/
115+
contextName: custom.Dockerfile
64116
```
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.

action.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,30 @@ inputs:
44
accessToken:
55
description: "GitHub Repository Token to log in using."
66
required: true
7-
context:
8-
description: "Where should GitHub Docker find the Dockerfile, relative to the root of the repository."
9-
required: false
10-
default: "."
11-
username:
12-
description: "GitHub user to publish the image on behalf of."
13-
required: false
14-
repositoryName:
15-
description: "The repository to push the image to. Defaults to current repository. Must be specified in format user/repo"
16-
required: false
177
imageName:
188
description: "The desired name for the image. Defaults to current repository name."
199
required: false
20-
imageTag:
21-
description: "The desired tag for the image. Defaults to current branch or release version number."
10+
tag:
11+
description: "The desired tag for the image. Defaults to latest. Optionally accepts multiple tags separated by newline."
12+
default: latest
2213
required: false
23-
imageTagPrefix:
24-
description: "Added to the beginning of the tag."
14+
buildArgs:
15+
description: "Any additional build arguments to use when building the image, separated by newline."
2516
required: false
26-
imageTagSuffix:
27-
description: "Added to the end of the tag."
17+
context:
18+
description: "Where should GitHub Docker find the Dockerfile, relative to the root of the repository."
19+
required: false
20+
default: "."
21+
contextName:
22+
description: "What Dockerfile should GitHub Docker be using when building. Defaults to traditional Dockerfile name."
2823
required: false
29-
buildArg:
30-
description: "The build arguments for image."
24+
default: Dockerfile
25+
repository:
26+
description: "The repository to push the image to. Defaults to the current repository. Must be specified in format user/repo."
3127
required: false
3228
outputs:
3329
imageURL:
34-
description: "The URL of the image."
30+
description: "The URL of the image, without the tag."
3531
runs:
3632
using: "node12"
3733
main: "dist/index.js"

checkrun/Dockerfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)