Skip to content

Commit 8c47d55

Browse files
author
Miguel Savignano
committed
update cli docs
1 parent 2883af8 commit 8c47d55

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,39 @@ Docker Hub
4343
image_name: devmasx/project-name
4444
```
4545
46+
## Usage
47+
4648
## Docker build
4749
4850
Use the latest docker image for use as cache
49-
Docker commands example:
5051
5152
```
52-
5353
npx cached-docker-build-push --image-name image-name --image-tag v1
5454

5555
```
5656

5757
Execute this docker commands:
5858

5959
```
60-
6160
docker pull image-name || exit 0
6261
docker build --cache-from=image-name -t image-name -t image-name:v1
6362
docker push image-name:v1
6463
docker push image-name
65-
6664
```
6765

6866
## Docker build with multi stage
6967

7068
With multi stage we need to save the builder stage for use as cache. Use the flag `--cache-stage-target` for define the builder stage
7169

7270
```
73-
7471
npx cached-docker-build-push --cache-stage-target=builder --image-name image-name --image-tag v1
75-
7672
```
7773

7874
Execute this docker commands:
7975

8076
```
77+
docker pull image-name:cache-builder || exit 0
8178
82-
docker pull image-name:cache-builder
8379
docker build \
8480
--cache-from=image-name:cache-builder \
8581
--target builder \
@@ -95,9 +91,10 @@ docker build \
9591
docker push image-name:cache-builder
9692
docker push image-name:v1
9793
docker push image-name
98-
9994
```
10095

101-
```
96+
### See more
10297

10398
```
99+
npx cached-docker-build-push --help
100+
```

action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: "cached-docker-build-push"
22
description: "Action for docker build and push with cache"
33
inputs:
44
image_name:
5-
description: "image_name"
5+
description: "Image name, required"
66
required: true
77
image_tag:
8-
description: "image_tag, default $GITHUB_SHA"
8+
description: "Image tag, default $GITHUB_SHA"
99
required: false
1010
cache_image_name:
11-
description: "cache_image_name"
11+
description: "Image name for the cache image, default $IMAGE_NAME:cache-$CACHE_STAGE_TARGET"
1212
required: false
1313
cache_stage_target:
14-
description: "cache_stage_target"
14+
description: "Name of the stage target for use in cache, two images will be compiled, the stage target and the last stage."
1515
required: false
1616
build_params:
17-
description: "Add multiple docker build params, example: --build-arg Dockerfile"
17+
description: "Add any docker build flag, --build-params='--build-arg=TOKEN=$TOKEN'"
1818
required: false
1919
runs:
2020
using: "node12"

bin/cached-docker-build-push.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22
const { dockerBuild } = require("../src/cached-docker-build-push");
33
const argv = require("minimist")(process.argv.slice(2));
44

5-
if (argv.help) {
5+
if (argv.help || Object.keys(argv).length == 1) {
66
return console.log(`
7-
usage: [--image-name] [--image-tag] [--cache-image-name]
8-
[--cache-stage-target] [--build-params]
7+
usage: [--image-name] [--image-tag] [--build-params]
8+
[--cache-stage-target] [--cache-image-name]
9+
10+
--image-name
11+
Image name, required
12+
13+
--image-tag
14+
Image tag, required
15+
16+
--build-params
17+
Add any docker build flag, --build-params="--build-arg=TOKEN=$TOKEN"
18+
19+
--cache-stage-target
20+
Name of the stage target for use in cache, two images will be compiled, the stage target and the last stage.
21+
22+
--cache-image-name
23+
Image name for the cache image, default $IMAGE_NAME:cache-$CACHE_STAGE_TARGET
924
`);
1025
}
1126

0 commit comments

Comments
 (0)