Skip to content

Commit 817ed59

Browse files
authored
Merge pull request #837 from crazy-max/update-workflows
ci: split validate and test workflow
2 parents f2a1d5e + a3646c0 commit 817ed59

File tree

9 files changed

+123
-238
lines changed

9 files changed

+123
-238
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ on:
1111
description: 'BuildKit image'
1212
default: 'moby/buildkit:buildx-stable-1'
1313
required: false
14+
schedule:
15+
- cron: '0 10 * * *'
1416
push:
1517
branches:
1618
- 'master'
19+
- 'releases/v*'
1720
pull_request:
18-
branches:
19-
- 'master'
2021

2122
env:
2223
BUILDX_VERSION: latest
@@ -199,6 +200,69 @@ jobs:
199200
exit 1
200201
fi
201202
203+
example:
204+
runs-on: ubuntu-latest
205+
env:
206+
DOCKER_IMAGE: localhost:5000/name/app
207+
services:
208+
registry:
209+
image: registry:2
210+
ports:
211+
- 5000:5000
212+
steps:
213+
-
214+
name: Checkout
215+
uses: actions/checkout@v3
216+
-
217+
name: Docker meta
218+
id: meta
219+
uses: docker/metadata-action@v4
220+
with:
221+
images: ${{ env.DOCKER_IMAGE }}
222+
tags: |
223+
type=schedule
224+
type=ref,event=branch
225+
type=ref,event=pr
226+
type=semver,pattern={{version}}
227+
type=semver,pattern={{major}}.{{minor}}
228+
type=semver,pattern={{major}}
229+
type=sha
230+
-
231+
name: Set up Docker Buildx
232+
uses: docker/setup-buildx-action@v2
233+
with:
234+
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
235+
driver-opts: |
236+
network=host
237+
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
238+
-
239+
name: Build and export to Docker client
240+
uses: ./
241+
with:
242+
context: ./test
243+
file: ./test/Dockerfile
244+
load: true
245+
tags: ${{ steps.meta.outputs.tags }}
246+
labels: ${{ steps.meta.outputs.labels }}
247+
-
248+
name: Build and push to local registry
249+
uses: ./
250+
with:
251+
context: ./test
252+
file: ./test/Dockerfile
253+
push: ${{ github.event_name != 'pull_request' }}
254+
tags: ${{ steps.meta.outputs.tags }}
255+
labels: ${{ steps.meta.outputs.labels }}
256+
-
257+
name: Inspect image
258+
run: |
259+
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
260+
-
261+
name: Check manifest
262+
if: github.event_name != 'pull_request'
263+
run: |
264+
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} --format '{{json .}}'
265+
202266
error:
203267
runs-on: ubuntu-latest
204268
steps:

.github/workflows/example.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ on:
44
push:
55
branches:
66
- 'master'
7+
- 'releases/v*'
78
pull_request:
8-
branches:
9-
- 'master'
109

1110
jobs:
1211
test:
@@ -15,11 +14,6 @@ jobs:
1514
-
1615
name: Checkout
1716
uses: actions/checkout@v3
18-
-
19-
name: Validate
20-
uses: docker/bake-action@v2
21-
with:
22-
targets: validate
2317
-
2418
name: Test
2519
uses: docker/bake-action@v2

.github/workflows/validate.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: validate
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'releases/v*'
8+
pull_request:
9+
10+
jobs:
11+
prepare:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
targets: ${{ steps.targets.outputs.matrix }}
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v3
19+
-
20+
name: Targets matrix
21+
id: targets
22+
run: |
23+
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
24+
25+
validate:
26+
runs-on: ubuntu-latest
27+
needs:
28+
- prepare
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
target: ${{ fromJson(needs.prepare.outputs.targets) }}
33+
steps:
34+
-
35+
name: Checkout
36+
uses: actions/checkout@v3
37+
-
38+
name: Validate
39+
uses: docker/bake-action@v2
40+
with:
41+
targets: ${{ matrix.target }}

.github/workflows/virtual-env.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

test/go/Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
FROM golang:1.19-alpine AS base
1+
# syntax=docker/dockerfile:1
2+
3+
FROM golang:alpine AS base
24
ENV CGO_ENABLED=0
35
RUN apk add --no-cache file git
46
WORKDIR /src
57

6-
FROM base as build
7-
COPY go.mod go.sum ./
8-
RUN go mod download -x
9-
COPY . .
10-
RUN go build -ldflags "-s -w" -o /usr/bin/app .
8+
FROM base AS build
9+
RUN --mount=type=bind,target=/src \
10+
--mount=type=cache,target=/root/.cache/go-build \
11+
go build -ldflags "-s -w" -o /usr/bin/app .
1112

1213
FROM scratch AS binary
1314
COPY --from=build /usr/bin/app /bin/app
1415

15-
FROM alpine:3.17 AS image
16+
FROM alpine AS image
1617
COPY --from=build /usr/bin/app /bin/app
18+
EXPOSE 8080
19+
ENTRYPOINT ["/bin/app"]

test/go/go.mod

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
11
module github.com/docker/build-push-action/test/go
22

33
go 1.18
4-
5-
require github.com/labstack/echo/v4 v4.9.1
6-
7-
require (
8-
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
9-
github.com/labstack/gommon v0.4.0 // indirect
10-
github.com/mattn/go-colorable v0.1.11 // indirect
11-
github.com/mattn/go-isatty v0.0.14 // indirect
12-
github.com/valyala/bytebufferpool v1.0.0 // indirect
13-
github.com/valyala/fasttemplate v1.2.1 // indirect
14-
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
15-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
16-
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
17-
golang.org/x/text v0.3.7 // indirect
18-
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
19-
)

test/go/go.sum

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)