Skip to content

Commit 1a16b8b

Browse files
committed
Add otel-collector ci
1 parent 934ec2d commit 1a16b8b

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: OTEL Collector Docker Image CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
- 'charts/**'
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
packages: write
18+
id-token: write
19+
contents: read
20+
actions: read
21+
security-events: write
22+
env:
23+
REGISTRY: ghcr.io
24+
GH_URL: https://github.com
25+
steps:
26+
- name: Checkout GitHub Action
27+
uses: actions/checkout@v3
28+
29+
- name: Set up Docker Buildx
30+
id: buildx
31+
uses: docker/setup-buildx-action@v2
32+
33+
- name: Docker metadata
34+
id: metadata
35+
uses: docker/metadata-action@v4
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector
38+
tags: |
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
42+
flavor: |
43+
latest=true
44+
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@v2
47+
with:
48+
registry: ${{ env.REGISTRY }}
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
-
53+
name: Set up Go
54+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed #5.1.0
55+
with:
56+
go-version: "1.22"
57+
cache: false
58+
59+
-
60+
name: Build OpenTelemetry Collector
61+
working-directory: otel-collector
62+
run: |
63+
curl --proto '=https' --tlsv1.2 -fL -o ocb https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv0.112.0/ocb_0.112.0_linux_amd64
64+
chmod +x ocb
65+
./ocb --config builder-config.yaml
66+
cp _build/kubviz-otel-collector .
67+
68+
- name: Build image and push to GitHub Container Registry
69+
uses: docker/build-push-action@v4
70+
with:
71+
context: otel-collector
72+
file: ./otel-collector/Dockerfile
73+
tags: ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:${{ github.run_id }}
74+
labels: ${{ steps.metadata.outputs.labels }}
75+
76+
push: true
77+
78+
- name: Install cosign
79+
uses: sigstore/cosign-installer@main
80+
81+
- name: Sign the images
82+
run: |
83+
cosign sign -y ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:${{ github.run_id }}
84+
env:
85+
COSIGN_EXPERIMENTAL: 1
86+
87+
- name: Verify the pushed tags
88+
run: cosign verify ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:${{ github.run_id }} --certificate-identity ${{ env.GH_URL }}/${{ github.repository }}/.github/workflows/otel-collector-image.yml@refs/heads/main --certificate-oidc-issuer https://token.actions.githubusercontent.com
89+
env:
90+
COSIGN_EXPERIMENTAL: 1
91+
92+
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
93+
uses: aquasecurity/trivy-action@master
94+
with:
95+
scan-type: 'fs'
96+
format: 'github'
97+
output: 'dependency-results.sbom.json'
98+
image-ref: '.'
99+
github-pat: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: OTEL Collector Docker Image CI
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**.md'
7+
- 'charts/**'
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
env:
15+
REGISTRY: ghcr.io
16+
GH_URL: https://github.com
17+
steps:
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
-
25+
name: Set up QEMU
26+
uses: docker/setup-qemu-action@v2
27+
28+
- uses: docker/setup-buildx-action@v1
29+
name: Set up Docker Buildx
30+
31+
-
32+
name: Login to ghcr registry
33+
uses: docker/login-action@v2
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
-
40+
name: Set up Go
41+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed #5.1.0
42+
with:
43+
go-version: "1.22"
44+
cache: false
45+
46+
-
47+
name: Build OpenTelemetry Collector
48+
working-directory: otel-collector
49+
run: |
50+
curl --proto '=https' --tlsv1.2 -fL -o ocb https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv0.112.0/ocb_0.112.0_linux_amd64
51+
chmod +x ocb
52+
./ocb --config builder-config.yaml
53+
cp _build/kubviz-otel-collector .
54+
55+
-
56+
name: Build and push on PR
57+
uses: docker/build-push-action@v4
58+
if: github.event_name == 'pull_request'
59+
with:
60+
context: otel-collector
61+
file: ./otel-collector/Dockerfile
62+
push: true
63+
tags: ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:pr-${{ github.event.pull_request.number }}
64+
build-args: |
65+
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
66+
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: otel-collector-release
2+
on:
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
jobs:
7+
push_to_registry:
8+
name: Build and push Docker image github container registry.
9+
runs-on: ubuntu-20.04
10+
permissions:
11+
packages: write
12+
id-token: write
13+
contents: read
14+
actions: read
15+
security-events: write
16+
env:
17+
REGISTRY: ghcr.io
18+
GH_URL: https://github.com
19+
steps:
20+
- name: Set environment variable
21+
run: |
22+
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
23+
- name: Test environment variable
24+
run: echo ${{ env.RELEASE_VERSION }}
25+
- name: Check out GitHub repo
26+
uses: actions/checkout@v3
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v2
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
-
34+
name: Set up Go
35+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed #5.1.0
36+
with:
37+
go-version: "1.22"
38+
cache: false
39+
-
40+
name: Build OpenTelemetry Collector
41+
working-directory: otel-collector
42+
run: |
43+
curl --proto '=https' --tlsv1.2 -fL -o ocb https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv0.112.0/ocb_0.112.0_linux_amd64
44+
chmod +x ocb
45+
./ocb --config builder-config.yaml
46+
cp _build/kubviz-otel-collector .
47+
- name: Build image and push to GitHub Container Registry
48+
uses: docker/build-push-action@v4
49+
with:
50+
push: true
51+
context: otel-collector
52+
file: ./otel-collector/Dockerfile
53+
tags: ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:${{ env.RELEASE_VERSION }}
54+
- name: Install cosign
55+
uses: sigstore/cosign-installer@main
56+
- name: Sign the images
57+
run: |
58+
cosign sign -y ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:${{ env.RELEASE_VERSION }}
59+
env:
60+
COSIGN_EXPERIMENTAL: 1
61+
- name: Verify the pushed tags
62+
run: cosign verify ${{ env.REGISTRY }}/${{ github.repository }}/otel-collector:${{ env.RELEASE_VERSION }} --certificate-identity ${{ env.GH_URL }}/${{ github.repository }}/.github/workflows/otel-collector-release.yml@refs/tags/${{ env.RELEASE_VERSION }} --certificate-oidc-issuer https://token.actions.githubusercontent.com
63+
env:
64+
COSIGN_EXPERIMENTAL: 1
65+
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
66+
uses: aquasecurity/trivy-action@master
67+
with:
68+
scan-type: 'fs'
69+
format: 'github'
70+
output: 'dependency-results.sbom.json'
71+
image-ref: '.'
72+
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT

0 commit comments

Comments
 (0)