generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker json config parameter + linting (#86)
* lint + added parameter * updated package json * updated licenses.txt file * README linting * Updating action.yml
- Loading branch information
Showing
8 changed files
with
527 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
# tag-push-action | ||
|
||
## About | ||
|
||
Github action to retag and push multiplatform images to multiple registries | ||
|
||
> :bulb: See also: | ||
> | ||
> * [login](https://github.com/docker/login-action) action | ||
> * [docker-meta](https://github.com/crazy-max/ghaction-docker-meta) action | ||
This action heavily relies on work done by [@tonistiigi](https://github.com/tonistiigi/repo-copy) and [@crazymax](https://github.com/docker/metadata-action) | ||
|
||
## Usage | ||
|
||
#### Basic | ||
### Basic | ||
|
||
```yaml | ||
name: Push-Image | ||
|
||
|
@@ -42,16 +46,15 @@ jobs: | |
quay.io/akhilerm/node-disk-manager-amd64:ci | ||
``` | ||
1. Login to all the registries from which you want to pull and push the multiplatform image. | ||
1. Login to all the registries from which you want to pull and push the multiplatform image. | ||
**NOTE: The source registry should be logged in after all destination regisries are logged in.** | ||
**NOTE: The source registry should be logged in after all destination registries are logged in.** | ||
2. Specify the `src` and `dst` registry, both of which are mandatory fields. The action allows multiple destination | ||
registries specified as a yaml string. | ||
2. Specify the `src` and `dst` registry, both of which are mandatory fields. The action allows multiple destination registries specified as a yaml string. | ||
|
||
**NOTE: If dockerhub is used, make sure that `docker.io` is specified in the image name** | ||
|
||
#### Using with `docker/metadata-action` | ||
### Using with `docker/metadata-action` | ||
|
||
The action can be used alongside [metadata-action](https://github.com/docker/metadata-action) to generate | ||
tags easily. | ||
|
@@ -87,3 +90,17 @@ jobs: | |
``` | ||
|
||
The output tags from the `meta` step can be used as destination tags for this github action. | ||
|
||
### Use a custom docker config file | ||
|
||
The standard docker config path on GitHub runner is `/home/runner/.docker/config.json`. In case you're running on a custom GitHub runner, and your config path is not standard, then the `docker-config-path` can be used. | ||
|
||
```yaml | ||
- name: Push image | ||
uses: akhilerm/[email protected] | ||
with: | ||
docker-config-path: /home/myuser/.docker/config.json | ||
src: docker.io/akhilerm/node-disk-manager:ci | ||
dst: | | ||
quay.io/akhilerm/node-disk-manager-amd64:ci | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,43 @@ | ||
import * as main from '../src/main'; | ||
import * as main from '../src/main' | ||
|
||
describe('getDestinationTags', () => { | ||
it('single image', async () => { | ||
await setInput('dst', 'akhilerm/linux-utils:ci'); | ||
const res = await main.getDestinationTags(); | ||
expect(res).toEqual(['akhilerm/linux-utils:ci']); | ||
}); | ||
await setInput('dst', 'akhilerm/linux-utils:ci') | ||
const res = await main.getDestinationTags() | ||
expect(res).toEqual(['akhilerm/linux-utils:ci']) | ||
}) | ||
|
||
it('multiple images', async () => { | ||
await setInput('dst', 'akhilerm/linux-utils:ci\nquay.io/akhilerm/linux-utils:ci'); | ||
const res = await main.getDestinationTags(); | ||
expect(res).toEqual(['akhilerm/linux-utils:ci', 'quay.io/akhilerm/linux-utils:ci']); | ||
}); | ||
await setInput( | ||
'dst', | ||
'akhilerm/linux-utils:ci\nquay.io/akhilerm/linux-utils:ci' | ||
) | ||
const res = await main.getDestinationTags() | ||
expect(res).toEqual([ | ||
'akhilerm/linux-utils:ci', | ||
'quay.io/akhilerm/linux-utils:ci' | ||
]) | ||
}) | ||
|
||
it('multiline images', async () => { | ||
await setInput('dst', `akhilerm/linux-utils:ci | ||
quay.io/akhilerm/linux-utils:ci`); | ||
const res = await main.getDestinationTags(); | ||
expect(res).toEqual(['akhilerm/linux-utils:ci', 'quay.io/akhilerm/linux-utils:ci']); | ||
}); | ||
}); | ||
await setInput( | ||
'dst', | ||
`akhilerm/linux-utils:ci | ||
quay.io/akhilerm/linux-utils:ci` | ||
) | ||
const res = await main.getDestinationTags() | ||
expect(res).toEqual([ | ||
'akhilerm/linux-utils:ci', | ||
'quay.io/akhilerm/linux-utils:ci' | ||
]) | ||
}) | ||
}) | ||
|
||
function setInput(name: string, value: string): void { | ||
process.env[getInputName(name)] = value; | ||
process.env[getInputName(name)] = value | ||
} | ||
|
||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67 | ||
function getInputName(name: string): string { | ||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`; | ||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}` | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.