-
Notifications
You must be signed in to change notification settings - Fork 4
146 lines (136 loc) · 5.35 KB
/
build.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: build
on:
pull_request:
branches:
- master
push:
branches:
- master
permissions:
contents: read
packages: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
enable:
- PROCESS_AGENT=0 SECURITY_AGENT=0 TRACE_AGENT=0 BUILD_INTEGRATIONS_BUILDER=1
- PROCESS_AGENT=1 SECURITY_AGENT=0 TRACE_AGENT=0
- PROCESS_AGENT=1 SECURITY_AGENT=0 TRACE_AGENT=1
- PROCESS_AGENT=1 SECURITY_AGENT=1 TRACE_AGENT=1
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "${AGENT_TOOLSDIRECTORY}"
- name: Checkout
uses: actions/checkout@v4
- name: Setup environment variables
run: |
echo ${{ matrix.enable }} \
| xargs -n1 echo \
| xargs -n1 -I{} echo ENABLE_{} >> ${GITHUB_ENV}
- name: Cache docker layers
uses: actions/cache@v3
with:
path: /tmp/layer-cache
key: layer-cache-${{ matrix.enable }}-${{ hashFiles('*Dockerfile') }}
restore-keys: |
layer-cache-${{ matrix.enable }}-
layer-cache-
- name: Get image tag
id: tag
run: make show-image-tag
- name: Prepare cache and pull latest release to reuse layers
uses: seqsense/sq-actions/buildx-pull@main
id: layer-cache
with:
IMAGES: |
ghcr.io/${{ github.repository_owner }}/${{ steps.tag.outputs.tag }}
ghcr.io/${{ github.repository_owner }}/${{ steps.tag.outputs.tag }}-integrations-builder
- name: Set up Docker Buildx for enabling cache exporters
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
driver-opts: network=host
- name: Build images
timeout-minutes: 45
env:
BUILDX_OPTS: >-
${{ steps.layer-cache.outputs.buildx-opts }}
--cache-from type=local,src=/tmp/layer-cache/main
--cache-to type=local,mode=max,dest=/tmp/layer-cache/main
run: make docker-build BUILD_OPTS="${BUILD_OPTS}"
- name: Embed inline cache
timeout-minutes: 5
env:
BUILDX_OPTS: >-
--load
--cache-from type=local,src=/tmp/layer-cache/main
--cache-to type=inline
run: make docker-build BUILD_OPTS="${BUILD_OPTS}"
- name: Get image tag
id: full-tag
run: make show-image-full-tag
- name: Build integrations-builder
if: env.ENABLE_BUILD_INTEGRATIONS_BUILDER == 1
env:
BUILDX_OPTS: >-
--build-arg BASE_IMAGE_PREFIX=${{ steps.layer-cache.outputs.registry-addr }}/
${{ steps.layer-cache.outputs.buildx-opts }}
--cache-from type=local,src=/tmp/layer-cache/main
--cache-from type=local,src=/tmp/layer-cache/integ
--cache-to type=local,mode=max,dest=/tmp/layer-cache/integ
run: |
docker tag \
${{ steps.tag.outputs.tag }} \
${{ steps.layer-cache.outputs.registry-addr }}/${{ steps.tag.outputs.tag }}
docker push ${{ steps.layer-cache.outputs.registry-addr }}/${{ steps.tag.outputs.tag }}
make docker-build-integrations-builder
- name: Embed inline cache to integrations-builder
if: env.ENABLE_BUILD_INTEGRATIONS_BUILDER == 1
env:
BUILDX_OPTS: >-
--load
--build-arg BASE_IMAGE_PREFIX=${{ steps.layer-cache.outputs.registry-addr }}/
--cache-from type=local,src=/tmp/layer-cache/integ
--cache-to type=inline
run: make docker-build-integrations-builder
- name: Login to GitHub Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
docker tag \
${{ steps.tag.outputs.tag }} \
ghcr.io/${{ github.repository_owner }}/${{ steps.full-tag.outputs.full_tag }}
docker push \
ghcr.io/${{ github.repository_owner }}/${{ steps.full-tag.outputs.full_tag }}
docker tag \
${{ steps.tag.outputs.tag }} \
ghcr.io/${{ github.repository_owner }}/${{ steps.tag.outputs.tag }}
docker push \
ghcr.io/${{ github.repository_owner }}/${{ steps.tag.outputs.tag }}
- name: Deploy integrations-builder
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && env.ENABLE_BUILD_INTEGRATIONS_BUILDER == 1
run: |
docker tag \
${{ steps.tag.outputs.tag }}-integrations-builder \
ghcr.io/${{ github.repository_owner }}/${{ steps.full-tag.outputs.full_tag }}-integrations-builder
docker push \
ghcr.io/${{ github.repository_owner }}/${{ steps.full-tag.outputs.full_tag }}-integrations-builder
- name: Notify failure
uses: seqsense/sq-actions/notify-branch-build@main
if: failure() && github.event_name == 'push'
with:
title: ":x: Release failed"