@@ -4,78 +4,49 @@ This is a Github Action to allow you to run Container Diff in a
4
4
[ Github Actions] ( https://help.github.com/articles/about-github-actions/#about-github-actions )
5
5
workflow. The intended use case is to build a Docker container from the repository,
6
6
push it to Docker Hub, and then use container-diff to extract metadata for it that
7
- you can use in other workflows (such as deploying to Github pages). In
8
- the example below, we will show you how to build a container, push
9
- to Docker Hub, and then container diff. Here is the entire workflow:
7
+ you can use in other workflows (such as deploying to Github pages). You can also run
8
+ container diff to extract metadata for a container you've just built locally in the action.
10
9
11
- ## Example 1: Run Container Diff
10
+ ## 1. Action Parameters
12
11
13
- Given an existing container on Docker Hub, we can run container diff
14
- without doing any kind of build.
12
+ The action accepts the following parameters:
15
13
16
- ```
17
- workflow "Run container-diff isolated" {
18
- on = "push"
19
- resolves = ["list"]
20
- }
14
+ | Name | Description | Type| Default | Required |
15
+ | ------| -------------| -----| ---------| ----------|
16
+ | command | main command for container-diff | string | analyze | false |
17
+ | args | The full list of arguments to follow container-diff (see example below) | string | help | true |
21
18
22
- action "Run container-diff" {
23
- uses = "GoogleContainerTools/container-diff/actions@master"
24
- args = ["analyze vanessa/salad --type=file --output=/github/workspace/data.json --json"]
25
- }
19
+ See below for a simple example. Another interesting use case would be to generate metadata and upload
20
+ to an OCI registry using [ OCI Registry As Storage] ( https://oras.land/ ) .
26
21
27
- action "list" {
28
- needs = ["Run container-diff"]
29
- uses = "actions/bin/sh@master"
30
- runs = "ls"
31
- args = ["/github/workspace"]
32
- }
22
+ ## 2. Run Container Diff
23
+
24
+ Given an existing container on Docker Hub, we can run container diff
25
+ without doing any kind of build.
26
+
27
+ ``` yaml
28
+ name : Run container-diff
29
+
30
+ on :
31
+ pull_request : []
32
+
33
+ jobs :
34
+ container-diff :
35
+ name : Run container-diff
36
+ steps :
37
+ - name : Checkout
38
+ uses : actions/checkout@v4
39
+ - name : Run container-diff
40
+ uses : GoogleContainerTools/container-diff/actions@master
41
+ with :
42
+ # Note this command is the default and does not need to be included
43
+ command : analyze
44
+ args : vanessa/salad --type=file --output=./data.json --json
45
+ - name : View output
46
+ run : cat ./data.json
33
47
` ` `
34
48
35
49
In the above, we run container-diff to output apt and pip packages, history,
36
50
and the filesystem for the container "vanessa/salad" that already exists on
37
51
Docker Hub. We save the result to a data.json output file. The final step in
38
52
the workflow (list) is a courtesy to show that the data.json file is generated.
39
-
40
- ## Example 2: Build, Deploy, Run Container Diff
41
-
42
- This next example is slightly more complicated in that it will run container-diff
43
- after a container is built and deployed from a Dockerfile present in the repository.
44
-
45
- ```
46
- workflow "Run container-diff after deploy" {
47
- on = "push"
48
- resolves = ["Run container-diff"]
49
- }
50
-
51
- action "build" {
52
- uses = "actions/docker/cli@master"
53
- args = "build -t vanessa/salad ."
54
- }
55
-
56
- action "login" {
57
- uses = "actions/docker/login@master"
58
- secrets = ["DOCKER_USERNAME", "DOCKER_PASSWORD"]
59
- }
60
-
61
- action "push" {
62
- uses = "actions/docker/cli@master"
63
- args = "push vanessa/salad"
64
- }
65
-
66
- action "Run container-diff" {
67
- needs = ["build", "login", "push"]
68
- uses = "GoogleContainerTools/container-diff/actions@master"
69
- args = ["analyze vanessa/salad --type=file --output=/github/workspace/data.json --json"]
70
- }
71
-
72
- action "list" {
73
- needs = ["Run container-diff"]
74
- uses = "actions/bin/sh@master"
75
- runs = "ls"
76
- args = ["/github/workspace"]
77
- }
78
- ```
79
-
80
- The intended use case of the above would be to, whenever you update your
81
- container, deploy its metadata to Github pages (or elsewhere).
0 commit comments