Skip to content

Commit 49e24ef

Browse files
authored
Merge pull request #9 from crazy-max/test-workflow
setup workflow for integration tests
2 parents 1cabe83 + 9b07c7f commit 49e24ef

File tree

6 files changed

+177
-1
lines changed

6 files changed

+177
-1
lines changed

.github/workflows/.test.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: .test
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
permissions:
8+
contents: read
9+
10+
on:
11+
workflow_dispatch:
12+
push:
13+
branches:
14+
- 'main'
15+
tags:
16+
- 'v*'
17+
pull_request:
18+
19+
jobs:
20+
build-aws-single:
21+
uses: .github/workflows/build.yml
22+
permissions:
23+
contents: read
24+
packages: write
25+
id-token: write
26+
with:
27+
meta-images: |
28+
public.ecr.aws/q3b5f1u4/test-docker-action
29+
meta-tags: |
30+
type=raw,value=ghbuilder-${{ github.run_id }}
31+
build-file: test/hello.Dockerfile
32+
build-output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
33+
build-sbom: true
34+
secrets:
35+
registry-auths: |
36+
- registry: public.ecr.aws
37+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
38+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
39+
40+
build-aws:
41+
uses: .github/workflows/build.yml
42+
permissions:
43+
contents: read
44+
packages: write
45+
id-token: write
46+
with:
47+
meta-images: |
48+
public.ecr.aws/q3b5f1u4/test-docker-action
49+
meta-tags: |
50+
type=raw,value=ghbuilder-${{ github.run_id }}
51+
build-file: test/hello.Dockerfile
52+
build-output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
53+
build-sbom: true
54+
build-platforms: linux/amd64,linux/arm64
55+
secrets:
56+
registry-auths: |
57+
- registry: public.ecr.aws
58+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
59+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
60+
61+
build-ghcr:
62+
uses: .github/workflows/build.yml
63+
permissions:
64+
contents: read
65+
packages: write
66+
id-token: write
67+
with:
68+
meta-images: ghcr.io/docker/github-builder-test
69+
meta-tags: |
70+
type=raw,value=${{ github.run_id }}
71+
build-file: test/hello.Dockerfile
72+
build-output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
73+
build-sbom: true
74+
build-platforms: linux/amd64,linux/arm64
75+
secrets:
76+
registry-auths: |
77+
- registry: ghcr.io
78+
username: ${{ github.actor }}
79+
password: ${{ secrets.GITHUB_TOKEN }}
80+
81+
build-dockerhub-stage:
82+
uses: .github/workflows/build.yml
83+
permissions:
84+
contents: read
85+
packages: write
86+
id-token: write
87+
with:
88+
meta-images: registry-1-stage.docker.io/docker/github-builder-test
89+
meta-tags: |
90+
type=raw,value=${{ github.run_id }}
91+
build-file: test/hello.Dockerfile
92+
build-output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
93+
build-sbom: true
94+
build-platforms: linux/amd64,linux/arm64
95+
secrets:
96+
registry-auths: |
97+
- registry: registry-1-stage.docker.io
98+
username: ${{ vars.DOCKERHUB_STAGE_USERNAME }}
99+
password: ${{ secrets.DOCKERHUB_STAGE_TOKEN }}
100+
101+
build-ghcr-and-aws:
102+
uses: .github/workflows/build.yml
103+
permissions:
104+
contents: read
105+
packages: write
106+
id-token: write
107+
with:
108+
meta-images: |
109+
ghcr.io/docker/github-builder-test
110+
public.ecr.aws/q3b5f1u4/test-docker-action
111+
meta-tags: |
112+
type=raw,value=${{ github.run_id }}
113+
build-file: test/hello.Dockerfile
114+
build-output: ${{ github.event_name != 'pull_request' && 'registry' || 'cacheonly' }}
115+
build-sbom: true
116+
build-platforms: linux/amd64,linux/arm64
117+
secrets:
118+
registry-auths: |
119+
- registry: ghcr.io
120+
username: ${{ github.actor }}
121+
password: ${{ secrets.GITHUB_TOKEN }}
122+
- registry: public.ecr.aws
123+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
124+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
125+
126+
build-local:
127+
uses: .github/workflows/build.yml
128+
permissions:
129+
contents: read
130+
packages: write
131+
id-token: write
132+
with:
133+
build-file: test/hello.Dockerfile
134+
build-output: ${{ github.event_name != 'pull_request' && 'local' || 'cacheonly' }}
135+
build-sbom: true
136+
build-platforms: linux/amd64,linux/arm64

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
This repository provides official Docker-maintained [reusable GitHub Actions workflows](https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows)
77
to securely build container images using Docker best practices. The workflows
88
sign BuildKit-generated SLSA-compliant provenance attestations and align with
9-
the principles behind [Docker Hardened Images](https://docs.docker.com/dhi/how-to/use/),
9+
the principles behind [Docker Hardened Images](https://docs.docker.com/dhi/),
1010
enabling open source projects to follow a seamless path toward higher levels of
1111
security and trust.
1212

test/go.Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG GO_VERSION="1.25"
4+
5+
# xx is a helper for cross-compilation
6+
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.7.0 AS xx
7+
8+
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
9+
COPY --from=xx / /
10+
RUN apk add --no-cache file git
11+
ENV CGO_ENABLED=0
12+
WORKDIR /src
13+
14+
FROM base AS build
15+
ARG TARGETPLATFORM
16+
RUN --mount=type=bind,target=. \
17+
--mount=target=/root/.cache,type=cache \
18+
xx-go build -trimpath -o /out/myapp . \
19+
&& xx-verify --static /out/myapp
20+
ARG BUILDKIT_SBOM_SCAN_STAGE=true
21+
22+
FROM scratch
23+
COPY --from=build /out /

test/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/docker/github-builder/test
2+
3+
go 1.25.0

test/hello.Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM alpine AS base
2+
ARG TARGETPLATFORM
3+
RUN echo "Hello, World! This is ${TARGETPLATFORM}" > /hello.txt
4+
ARG BUILDKIT_SBOM_SCAN_STAGE=true
5+
6+
FROM scratch
7+
COPY --from=base /hello.txt /

test/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("hello world")
7+
}

0 commit comments

Comments
 (0)