Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 4292bbc

Browse files
committed
adding README and Dockerfile for Github actions, will test with my branch
1 parent 616e266 commit 4292bbc

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

actions/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM golang:1.11.3-stretch
2+
3+
# docker build -f actions/Dockerfile -t googlecontainertools/container-diff .
4+
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+
23+
LABEL "com.github.actions.name"="container-diff GitHub Action"
24+
LABEL "com.github.actions.description"="use Container-Diff in Github Actions Workflows"
25+
LABEL "com.github.actions.icon"="cloud"
26+
LABEL "com.github.actions.color"="blue"
27+
28+
LABEL "repository"="https://www.github.com/GoogleContainerTools/container-diff"
29+
LABEL "homepage"="https://www.github.com/GoogleContainerTools/container-diff"
30+
LABEL "maintainer"="Google Inc."
31+
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
40+
41+
RUN mkdir -p /root/.docker && \
42+
echo {} > /root/.docker/config.json
43+
44+
ENTRYPOINT ["container-diff"]

actions/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Container Diff for Github Actions
2+
3+
This is a Github Action to allow you to run Container Diff in a
4+
[Github Actions](https://help.github.com/articles/about-github-actions/#about-github-actions)
5+
workflow. The intended use case is to build a Docker container from the repository,
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:
10+
11+
## Example 1: Run Container Diff
12+
13+
Given an existing container on Docker Hub, we can run container diff
14+
without doing any kind of build.
15+
16+
```
17+
workflow "Run container-diff" {
18+
on = "push"
19+
resolves = ["list"]
20+
}
21+
22+
action "Run container-diff" {
23+
args = ["analyze", "vanessa/salad", "--type=pip", "type=apt", "--type=history", --output "/github/workspace/data.json", "--type=file", "--json", "--quiet", "--verbosity=panic" ]
24+
}
25+
26+
action "list" {
27+
needs = ["Run container-diff"]
28+
uses = "actions/bin/sh@master"
29+
runs = "ls"
30+
args = ["/github/workspace"]
31+
}
32+
```
33+
34+
In the above, we run container-diff to output apt and pip packages, history,
35+
and the filesystem for the container "vanessa/salad" that already exists on
36+
Docker Hub. We save the result to a data.json output file. The final step in
37+
the workflow (list) is a courtesy to show that the data.json file is generated.
38+
39+
## Example 2: Build, Deploy, Run Container Diff
40+
41+
This next example is slightly more complicated in that it will run container-diff
42+
after a container is built and deployed from a Dockerfile present in the repository.
43+
44+
```
45+
workflow "Run container-diff after deploy" {
46+
on = "push"
47+
resolves = ["Run container-diff"]
48+
}
49+
50+
action "build" {
51+
uses = "actions/docker/cli@master"
52+
args = "build -t vanessa/salad ."
53+
}
54+
55+
action "login" {
56+
uses = "actions/docker/login@master"
57+
secrets = ["DOCKER_USERNAME", "DOCKER_PASSWORD"]
58+
}
59+
60+
action "push" {
61+
uses = "actions/docker/cli@master"
62+
args = "push vanessa/salad"
63+
}
64+
65+
action "Run container-diff" {
66+
needs = ["build", "login", "push"]
67+
args = ["analyze", "vanessa/salad", "--type=pip", "type=apt", "--type=history", --output "/github/workspace/data.json", "--type=file", "--json", "--quiet", "--verbosity=panic" ]
68+
}
69+
70+
action "list" {
71+
needs = ["Run container-diff"]
72+
uses = "actions/bin/sh@master"
73+
runs = "ls"
74+
args = ["/github/workspace"]
75+
}
76+
```
77+
78+
The intended use case of the above would be to, whenever you update your
79+
container, deploy its metadata to Github pages (or elsewhere).

0 commit comments

Comments
 (0)