Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit d06e569

Browse files
committed
fix: add test for action and update readme
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent f4bd67b commit d06e569

File tree

5 files changed

+72
-98
lines changed

5 files changed

+72
-98
lines changed

‎.github/workflows/test-action.yaml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test container-diff Action
2+
3+
on:
4+
pull_request: []
5+
6+
jobs:
7+
test-container-diff:
8+
name: Test container-diff
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
# Add more test cases here as necessary
14+
args:
15+
- vanessa/salad --type=file --output=./data.json --json
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
- name: Run container-diff
20+
uses: ./actions
21+
with:
22+
args: ${{ matrix.args }}
23+
- name: View output
24+
run: cat ./data.json

‎actions/Dockerfile‎

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
FROM golang:1.11.3-stretch
1+
FROM debian:bookworm
22

33
# docker build -f actions/Dockerfile -t googlecontainertools/container-diff .
44

5-
RUN apt-get update && \
6-
apt-get install -y automake \
7-
libffi-dev \
8-
libxml2 \
9-
libxml2-dev \
10-
libxslt-dev \
11-
libxslt1-dev \
12-
git \
13-
gcc g++ \
14-
wget \
15-
locales
16-
17-
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
18-
locale-gen
19-
ENV LANG en_US.UTF-8
20-
ENV LANGUAGE en_US:en
21-
ENV LC_ALL en_US.UTF-8
22-
235
LABEL "com.github.actions.name"="container-diff GitHub Action"
246
LABEL "com.github.actions.description"="use Container-Diff in Github Actions Workflows"
257
LABEL "com.github.actions.icon"="cloud"
@@ -29,14 +11,10 @@ LABEL "repository"="https://www.github.com/GoogleContainerTools/container-diff"
2911
LABEL "homepage"="https://www.github.com/GoogleContainerTools/container-diff"
3012
LABEL "maintainer"="Google Inc."
3113

32-
# Install container-diff from master
33-
RUN go get github.com/GoogleContainerTools/container-diff && \
34-
cd ${GOPATH}/src/github.com/GoogleContainerTools/container-diff && \
35-
go get && \
36-
make && \
37-
go install && \
38-
mkdir -p /code && \
39-
apt-get autoremove
14+
# Install container-diff latest release
15+
RUN apt-get update && apt-get install -y curl && \
16+
curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && \
17+
install container-diff-linux-amd64 /usr/local/bin/container-diff
4018

4119
ADD entrypoint.sh /entrypoint.sh
4220

‎actions/README.md‎

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,49 @@ This is a Github Action to allow you to run Container Diff in a
44
[Github Actions](https://help.github.com/articles/about-github-actions/#about-github-actions)
55
workflow. The intended use case is to build a Docker container from the repository,
66
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.
109

11-
## Example 1: Run Container Diff
10+
## 1. Action Parameters
1211

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:
1513

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 |
2118

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/).
2621

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
3347
```
3448
3549
In the above, we run container-diff to output apt and pip packages, history,
3650
and the filesystem for the container "vanessa/salad" that already exists on
3751
Docker Hub. We save the result to a data.json output file. The final step in
3852
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).
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: container-diff
22

33
inputs:
4-
argument:
4+
command:
55
required: true
6+
description: "Container diff command to use (defaults to analyze)"
7+
default: analyze
8+
args:
69
description: "String of arguments to pass to the container-diff command"
710
default: help
811

912
runs:
1013
using: 'docker'
11-
image: 'action/Dockerfile'
12-
args:
13-
- ${{ inputs.argument }}
14-
14+
image: 'Dockerfile'

‎actions/entrypoint.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
22

3-
echo "$@"
4-
/go/bin/container-diff ${@}
3+
command="${INPUT_COMMAND} ${INPUT_ARGS}"
4+
echo "container-diff ${command}"
5+
/usr/local/bin/container-diff ${command}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /