Skip to content

Commit 0b1ac42

Browse files
authored
Docker json config parameter + linting (#86)
* lint + added parameter * updated package json * updated licenses.txt file * README linting * Updating action.yml
1 parent 646e5fc commit 0b1ac42

File tree

8 files changed

+527
-235
lines changed

8 files changed

+527
-235
lines changed

README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
# tag-push-action
2+
13
## About
24

35
Github action to retag and push multiplatform images to multiple registries
46

57
> :bulb: See also:
8+
>
69
> * [login](https://github.com/docker/login-action) action
710
> * [docker-meta](https://github.com/crazy-max/ghaction-docker-meta) action
811
912
This action heavily relies on work done by [@tonistiigi](https://github.com/tonistiigi/repo-copy) and [@crazymax](https://github.com/docker/metadata-action)
1013

1114
## Usage
1215

13-
#### Basic
16+
### Basic
17+
1418
```yaml
1519
name: Push-Image
1620

@@ -42,16 +46,15 @@ jobs:
4246
quay.io/akhilerm/node-disk-manager-amd64:ci
4347
```
4448
45-
1. Login to all the registries from which you want to pull and push the multiplatform image.
49+
1. Login to all the registries from which you want to pull and push the multiplatform image.
4650
47-
**NOTE: The source registry should be logged in after all destination regisries are logged in.**
51+
**NOTE: The source registry should be logged in after all destination registries are logged in.**
4852
49-
2. Specify the `src` and `dst` registry, both of which are mandatory fields. The action allows multiple destination
50-
registries specified as a yaml string.
53+
2. Specify the `src` and `dst` registry, both of which are mandatory fields. The action allows multiple destination registries specified as a yaml string.
5154

5255
**NOTE: If dockerhub is used, make sure that `docker.io` is specified in the image name**
5356

54-
#### Using with `docker/metadata-action`
57+
### Using with `docker/metadata-action`
5558

5659
The action can be used alongside [metadata-action](https://github.com/docker/metadata-action) to generate
5760
tags easily.
@@ -87,3 +90,17 @@ jobs:
8790
```
8891

8992
The output tags from the `meta` step can be used as destination tags for this github action.
93+
94+
### Use a custom docker config file
95+
96+
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.
97+
98+
```yaml
99+
- name: Push image
100+
uses: akhilerm/[email protected]
101+
with:
102+
docker-config-path: /home/myuser/.docker/config.json
103+
src: docker.io/akhilerm/node-disk-manager:ci
104+
dst: |
105+
quay.io/akhilerm/node-disk-manager-amd64:ci
106+
```

__tests__/main.test.ts

+29-18
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
1-
import * as main from '../src/main';
1+
import * as main from '../src/main'
22

33
describe('getDestinationTags', () => {
44
it('single image', async () => {
5-
await setInput('dst', 'akhilerm/linux-utils:ci');
6-
const res = await main.getDestinationTags();
7-
expect(res).toEqual(['akhilerm/linux-utils:ci']);
8-
});
5+
await setInput('dst', 'akhilerm/linux-utils:ci')
6+
const res = await main.getDestinationTags()
7+
expect(res).toEqual(['akhilerm/linux-utils:ci'])
8+
})
99

1010
it('multiple images', async () => {
11-
await setInput('dst', 'akhilerm/linux-utils:ci\nquay.io/akhilerm/linux-utils:ci');
12-
const res = await main.getDestinationTags();
13-
expect(res).toEqual(['akhilerm/linux-utils:ci', 'quay.io/akhilerm/linux-utils:ci']);
14-
});
11+
await setInput(
12+
'dst',
13+
'akhilerm/linux-utils:ci\nquay.io/akhilerm/linux-utils:ci'
14+
)
15+
const res = await main.getDestinationTags()
16+
expect(res).toEqual([
17+
'akhilerm/linux-utils:ci',
18+
'quay.io/akhilerm/linux-utils:ci'
19+
])
20+
})
1521

1622
it('multiline images', async () => {
17-
await setInput('dst', `akhilerm/linux-utils:ci
18-
quay.io/akhilerm/linux-utils:ci`);
19-
const res = await main.getDestinationTags();
20-
expect(res).toEqual(['akhilerm/linux-utils:ci', 'quay.io/akhilerm/linux-utils:ci']);
21-
});
22-
});
23+
await setInput(
24+
'dst',
25+
`akhilerm/linux-utils:ci
26+
quay.io/akhilerm/linux-utils:ci`
27+
)
28+
const res = await main.getDestinationTags()
29+
expect(res).toEqual([
30+
'akhilerm/linux-utils:ci',
31+
'quay.io/akhilerm/linux-utils:ci'
32+
])
33+
})
34+
})
2335

2436
function setInput(name: string, value: string): void {
25-
process.env[getInputName(name)] = value;
37+
process.env[getInputName(name)] = value
2638
}
2739

2840
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
2941
function getInputName(name: string): string {
30-
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
42+
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`
3143
}
32-

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
dst:
99
required: true
1010
description: 'Destination tags'
11+
docker-config-path:
12+
required: false
13+
description: 'Docker config file path'
1114
runs:
1215
using: 'node12'
1316
main: 'dist/index.js'

0 commit comments

Comments
 (0)