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

Commit

Permalink
Adjust and merge new features into master (#19)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Jun 14, 2020
1 parent 3388e8a commit 6467451
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 1,271 deletions.
17 changes: 0 additions & 17 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @matootie
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: [matootie, 123FLO321]
github: matootie
33 changes: 33 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "GitHub Docker"
on:
push:
paths:
- ".github/workflows/CI.yml"
- "dist/index.js"
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-16.04
- ubuntu-18.04
- ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Run the action
uses: ./
id: publish
with:
accessToken: ${{ github.token }}
imageName: action-test
tag: |
latest-${{ matrix.os }}
test-${{ matrix.os }}
buildArgs: |
TESTARG1=test1
TESTARG2=test2
context: test/
contextName: test.Dockerfile
24 changes: 0 additions & 24 deletions .github/workflows/test.yml

This file was deleted.

10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

### v3.0.0

* `contextName` can now be specified for GitHub Docker to find Dockerfiles with custom names.
* Removed `username` input.
* Renamed `repositoryName` to just `repository`.
* Replaced `imageTag` with `tag`. Multiple tags can be specified via newline.
* Tag now defaults to `latest`, as appose to commit SHA.
* Removed `imageTagPrefix` and `imageTagSuffix` inputs.
126 changes: 96 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,127 @@ Build and publish your repository as a Docker image and push it to GitHub Packag

## Inputs

### `accessToken`
| Name | Requirement | Description |
| --------------------- | ----------------- | ------------|
| `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 }}`.
| `imageName` | ***Optional*** | The desired name for the image. Defaults to current repository name.
| `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)_.
| `buildArgs` | ***Optional*** | Any additional build arguments to use when building the image, separated by newline. _See [example below](#publishing-using-build-arguments)_.
| `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)_.
| `contextName` | ***Optional*** | What Dockerfile should GitHub Docker be using when building. Defaults to traditional `Dockerfile` name. _See [example below](#publishing-using-custom-context)_.
| `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)_.

**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 }}`.
## Outputs

### `context`
| With Parameter | Description |
| --------------------- | ------------------------------------------ |
| `imageURL` | The URL of the image, **without** the tag. |

*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.
## Example usage

### `username`
#### Simple, minimal usage...

*Optional*. GitHub user to publish the image on behalf of. Defaults to the user who triggered the action to run.
```yaml
- name: Publish Image
uses: matootie/github-docker:v3.0.0
with:
accessToken: ${{ github.token }}
```
### `repositoryName`
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!
*Optional*. The repository to push the image to. Defaults to current repository. Must be specified in format `user/repo`.
For additional customizations, see further examples below. For more information on the output URL, see [this example](#publishing-and-using-output).
### `imageName`
#### Publishing using custom tag...
```yaml
- name: Publish Image
uses: matootie/github-docker:v3.0.0
with:
accessToken: ${{ github.token }}
tag: latest
```
*Optional*. The desired name for the image. Defaults to current repository name.
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.
### `imageTag`
#### Publishing using several tags...
*Optional*. The desired tag for the image. Defaults to current branch or release version number.
```yaml
- name: Publish Image
uses: matootie/github-docker:v3.0.0
with:
accessToken: ${{ github.token }}
tag: |
latest
${{ github.sha }}
```
### `imageTagPrefix`
In this example we publish the same image under two different tags.
*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.
#### Publishing using build arguments...
### `imageTagSuffix`
```yaml
- name: Publish Image
uses: matootie/github-docker:v3.0.0
with:
accessToken: ${{ github.token }}
buildArgs: |
ENVIRONMENT=test
SOME_OTHER_ARG=yes
```
*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.
Using build arguments is easy, just set each one on its own individual line, similarly to how you would in a `.env` file.

### `buildArg`
#### Publishing and using output...

*Optional*. Any additional build arguments to use when building the image.
```yaml
with:
buildArg: |
HTTP_PROXY=http://10.20.30.2:1234
FTP_PROXY=http://40.50.60.5:4567
- name: Publish Image
uses: matootie/github-docker:v3.0.0
id: publish
with:
accessToken: ${{ github.token }}
- name: Print Image URL
run: echo ${{ steps.publish.outputs.imageURL }}
```

## Outputs
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...

### `imageURL`
```yaml
- name: Publish Image
uses: matootie/github-docker:v3.0.0
id: publish
with:
accessToken: ${{ github.token }}
tag: ${{ github.sha }}
- name: Print Full Image URL
run: echo ${{ stets.publish.outputs.imageURL }}/${{ github.sha }}
```

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

## Simple usage
#### Publishing using custom context...

```yaml
- name: Checkout Repository
uses: actions/checkout@v2
- name: Publish Image
uses: matootie/github-docker@v2.2.2
uses: matootie/github-docker:v3.0.0
with:
accessToken: ${{ secrets.GITHUB_TOKEN }}
accessToken: ${{ github.token }}
context: custom/context/dir/
contextName: custom.Dockerfile
```

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.

#### Publishing to a different repository.

```yaml
- name: Publish Image
uses: matootie/github-docker:v3.0.0
with:
accessToken: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: my-user/my-repo
```

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.
34 changes: 15 additions & 19 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,30 @@ inputs:
accessToken:
description: "GitHub Repository Token to log in using."
required: true
context:
description: "Where should GitHub Docker find the Dockerfile, relative to the root of the repository."
required: false
default: "."
username:
description: "GitHub user to publish the image on behalf of."
required: false
repositoryName:
description: "The repository to push the image to. Defaults to current repository. Must be specified in format user/repo"
required: false
imageName:
description: "The desired name for the image. Defaults to current repository name."
required: false
imageTag:
description: "The desired tag for the image. Defaults to current branch or release version number."
tag:
description: "The desired tag for the image. Defaults to latest. Optionally accepts multiple tags separated by newline."
default: latest
required: false
imageTagPrefix:
description: "Added to the beginning of the tag."
buildArgs:
description: "Any additional build arguments to use when building the image, separated by newline."
required: false
imageTagSuffix:
description: "Added to the end of the tag."
context:
description: "Where should GitHub Docker find the Dockerfile, relative to the root of the repository."
required: false
default: "."
contextName:
description: "What Dockerfile should GitHub Docker be using when building. Defaults to traditional Dockerfile name."
required: false
buildArg:
description: "The build arguments for image."
default: Dockerfile
repository:
description: "The repository to push the image to. Defaults to the current repository. Must be specified in format user/repo."
required: false
outputs:
imageURL:
description: "The URL of the image."
description: "The URL of the image, without the tag."
runs:
using: "node12"
main: "dist/index.js"
Expand Down
2 changes: 0 additions & 2 deletions checkrun/Dockerfile

This file was deleted.

Loading

0 comments on commit 6467451

Please sign in to comment.