generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 8
81 lines (70 loc) · 2.45 KB
/
pr-build-image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Build Image
on:
pull_request_target:
types: [opened, edited, synchronize, reopened, ready_for_review]
branches:
- "main"
- "release-*"
push:
branches:
- "main"
- "release-*"
jobs:
envs:
runs-on: ubuntu-latest
outputs:
build-args: ${{ steps.prepare-envs.outputs.build-args }}
tags: ${{ steps.create-tags.outputs.tags }}
otel-version: ${{ steps.load-envs.outputs.OTEL_VERSION }}
otel-contrib-version: ${{ steps.load-envs.outputs.OTEL_CONTRIB_VERSION }}
pr-tag: ${{ steps.create-tags.outputs.PR_TAG }}
push-tag: ${{ steps.create-tags.outputs.PUSH_TAG }}
steps:
- name: Checkout code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout code
if: github.event_name == 'push'
uses: actions/checkout@v4
- name: prepare envs
id: prepare-envs
run: |
{
echo 'build-args<<BUILD_ARGS'
cat otel-collector/envs
echo BUILD_ARGS
} >> "$GITHUB_OUTPUT"
- name: load envs into output
id: load-envs
run: |
cat otel-collector/envs >> "$GITHUB_OUTPUT"
- name: print env context
run: echo "${{ steps.prepare-envs.outputs.build-args }}"
- name: create tags
id: create-tags
run: |
if [[ $GITHUB_EVENT_NAME == 'push' ]]; then
echo 'TAGS="${{ steps.load-envs.outputs.OTEL_VERSION }}-${{ github.ref_name }}"' >> "$GITHUB_OUTPUT"
else
echo 'TAGS="PR-${{ github.event.pull_request.number }}"' >> "$GITHUB_OUTPUT"
fi
echo 'PUSH_TAG="${{ steps.load-envs.outputs.OTEL_VERSION }}-${{ github.ref_name }}"' >> "$GITHUB_OUTPUT"
echo 'PR_TAG="PR-${{ github.event.pull_request.number }}"' >> "$GITHUB_OUTPUT"
build-image:
needs: envs
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main # Usage: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: kyma-otel-collector
dockerfile: otel-collector/Dockerfile
context: .
build-args: ${{ needs.envs.outputs.build-args }}
tags: ${{ needs.envs.outputs.tags }}
Build-Image-Success:
needs: build-image
runs-on: ubuntu-latest
steps:
- name: List images
run: |
echo "${{ needs.build-image.outputs.images }}"