|
1 | 1 | # Copyright The OpenTelemetry Authors
|
2 | 2 | # SPDX-License-Identifier: Apache-2.0
|
| 3 | +name: Test image generation |
3 | 4 |
|
4 | 5 | on:
|
5 | 6 | push:
|
6 | 7 | paths:
|
7 | 8 | - 'src/**'
|
8 | 9 | - 'test/**'
|
9 |
| - workflow_call: |
10 |
| - inputs: |
11 |
| - push: |
12 |
| - description: Should the images be pushed |
13 |
| - default: false |
14 |
| - required: false |
15 |
| - type: boolean |
16 |
| - version: |
17 |
| - description: The version used when tagging the image |
18 |
| - default: 'dev' |
19 |
| - required: false |
20 |
| - type: string |
21 | 10 |
|
22 | 11 | jobs:
|
23 |
| - build_and_push_images: |
| 12 | + build_images: |
24 | 13 | if: github.repository == 'open-telemetry/opentelemetry-demo'
|
25 |
| - runs-on: ubuntu-latest |
26 |
| - permissions: |
27 |
| - contents: read |
28 |
| - packages: write |
29 |
| - |
30 |
| - env: |
31 |
| - RELEASE_VERSION: "${{ github.event.release.tag_name }}" |
32 |
| - DOCKERHUB_REPO: "otel/demo" |
33 |
| - GHCR_REPO: "ghcr.io/open-telemetry/demo" |
34 |
| - |
35 |
| - strategy: |
36 |
| - fail-fast: false |
37 |
| - matrix: |
38 |
| - file_tag: |
39 |
| - - file: ./src/accountingservice/Dockerfile |
40 |
| - tag_suffix: accountingservice |
41 |
| - context: ./ |
42 |
| - setup-qemu: true |
43 |
| - - file: ./src/adservice/Dockerfile |
44 |
| - tag_suffix: adservice |
45 |
| - context: ./ |
46 |
| - setup-qemu: true |
47 |
| - - file: ./src/cartservice/src/Dockerfile |
48 |
| - tag_suffix: cartservice |
49 |
| - context: ./ |
50 |
| - setup-qemu: false |
51 |
| - - file: ./src/checkoutservice/Dockerfile |
52 |
| - tag_suffix: checkoutservice |
53 |
| - context: ./ |
54 |
| - setup-qemu: true |
55 |
| - - file: ./src/currencyservice/Dockerfile |
56 |
| - tag_suffix: currencyservice |
57 |
| - context: ./ |
58 |
| - setup-qemu: true |
59 |
| - - file: ./src/emailservice/Dockerfile |
60 |
| - tag_suffix: emailservice |
61 |
| - context: ./src/emailservice |
62 |
| - setup-qemu: true |
63 |
| - - file: ./src/frauddetectionservice/Dockerfile |
64 |
| - tag_suffix: frauddetectionservice |
65 |
| - context: ./ |
66 |
| - setup-qemu: true |
67 |
| - - file: ./src/frontend/Dockerfile |
68 |
| - tag_suffix: frontend |
69 |
| - context: ./ |
70 |
| - setup-qemu: true |
71 |
| - - file: ./src/frontendproxy/Dockerfile |
72 |
| - tag_suffix: frontendproxy |
73 |
| - context: ./ |
74 |
| - setup-qemu: true |
75 |
| - - file: ./src/frontend/Dockerfile.cypress |
76 |
| - tag_suffix: frontend-tests |
77 |
| - context: ./ |
78 |
| - setup-qemu: true |
79 |
| - - file: ./src/imageprovider/Dockerfile |
80 |
| - tag_suffix: imageprovider |
81 |
| - context: ./ |
82 |
| - setup-qemu: true |
83 |
| - - file: ./src/kafka/Dockerfile |
84 |
| - tag_suffix: kafka |
85 |
| - context: ./ |
86 |
| - setup-qemu: true |
87 |
| - - file: ./src/loadgenerator/Dockerfile |
88 |
| - tag_suffix: loadgenerator |
89 |
| - context: ./ |
90 |
| - setup-qemu: true |
91 |
| - - file: ./src/paymentservice/Dockerfile |
92 |
| - tag_suffix: paymentservice |
93 |
| - context: ./ |
94 |
| - setup-qemu: true |
95 |
| - - file: ./src/productcatalogservice/Dockerfile |
96 |
| - tag_suffix: productcatalogservice |
97 |
| - context: ./ |
98 |
| - setup-qemu: true |
99 |
| - - file: ./src/quoteservice/Dockerfile |
100 |
| - tag_suffix: quoteservice |
101 |
| - context: ./ |
102 |
| - setup-qemu: true |
103 |
| - - file: ./src/recommendationservice/Dockerfile |
104 |
| - tag_suffix: recommendationservice |
105 |
| - context: ./ |
106 |
| - setup-qemu: true |
107 |
| - - file: ./src/shippingservice/Dockerfile |
108 |
| - tag_suffix: shippingservice |
109 |
| - context: ./ |
110 |
| - setup-qemu: true |
111 |
| - - file: ./test/tracetesting/Dockerfile |
112 |
| - tag_suffix: traceBasedTests |
113 |
| - context: ./ |
114 |
| - setup-qemu: true |
115 |
| - |
116 |
| - steps: |
117 |
| - - uses: actions/checkout@v4 |
118 |
| - with: |
119 |
| - fetch-depth: 0 |
120 |
| - - name: Check for changes and set push options |
121 |
| - id: check_changes |
122 |
| - run: | |
123 |
| - DOCKERFILE_DIR=$(dirname ${{ matrix.file_tag.file }}) |
124 |
| - FILES_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- $DOCKERFILE_DIR) |
125 |
| - FORCE_PUSH=${{ inputs.push }} |
126 |
| - if [ "$FORCE_PUSH" = true ]; then |
127 |
| - echo "Force push is enabled, proceeding with build." |
128 |
| - echo "skip=false" >> "$GITHUB_OUTPUT" |
129 |
| - elif [ -z "$FILES_CHANGED" ]; then |
130 |
| - echo "No changes in ${{ matrix.file_tag.context }}, skipping build." |
131 |
| - echo "skip=true" >> "$GITHUB_OUTPUT" |
132 |
| - else |
133 |
| - echo "Changes detected in ${{ matrix.file_tag.context }}, proceeding with build." |
134 |
| - echo "skip=false" >> "$GITHUB_OUTPUT" |
135 |
| - fi |
136 |
| - - name: Log in to the Container registry |
137 |
| - uses: docker/login-action@v3 |
138 |
| - with: |
139 |
| - registry: ghcr.io |
140 |
| - username: ${{ github.repository_owner }} |
141 |
| - password: ${{ secrets.GITHUB_TOKEN }} |
142 |
| - if: ${{ inputs.push }} |
143 |
| - - name: Log in to Docker Hub |
144 |
| - uses: docker/login-action@v3 |
145 |
| - with: |
146 |
| - username: ${{ secrets.DOCKER_USERNAME }} |
147 |
| - password: ${{ secrets.DOCKER_PASSWORD }} |
148 |
| - if: ${{ inputs.push }} |
149 |
| - - name: Set up QEMU |
150 |
| - if: ${{ matrix.file_tag.setup-qemu }} |
151 |
| - uses: docker/setup-qemu-action@v3 |
152 |
| - with: |
153 |
| - image: tonistiigi/binfmt:master |
154 |
| - - name: Set up Docker Buildx |
155 |
| - uses: docker/setup-buildx-action@v3 |
156 |
| - with: |
157 |
| - config-inline: | |
158 |
| - [worker.oci] |
159 |
| - max-parallelism = 2 |
160 |
| - - name: Matrix Build and push demo images |
161 |
| - if: steps.check_changes.outputs.skip == 'false' |
162 |
| - |
163 |
| - with: |
164 |
| - context: ${{ matrix.file_tag.context }} |
165 |
| - file: ${{ matrix.file_tag.file }} |
166 |
| - platforms: linux/amd64,linux/arm64 |
167 |
| - push: ${{ inputs.push }} |
168 |
| - tags: | |
169 |
| - ${{ env.DOCKERHUB_REPO }}:${{ inputs.version }}-${{matrix.file_tag.tag_suffix }} |
170 |
| - ${{ env.DOCKERHUB_REPO }}:latest-${{matrix.file_tag.tag_suffix }} |
171 |
| - ${{ env.GHCR_REPO }}:${{ inputs.version }}-${{ matrix.file_tag.tag_suffix }} |
172 |
| - ${{ env.GHCR_REPO }}:latest-${{ matrix.file_tag.tag_suffix }} |
173 |
| - cache-from: type=gha |
174 |
| - cache-to: type=gha |
| 14 | + uses: ./.github/workflows/component_build_images.yml |
0 commit comments