This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
forked from gardener-attic/connectivity-exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (104 loc) · 3.27 KB
/
build.yml
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
name: Compilation
on:
push:
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
with:
go-version: 1.16
id: go
- name: Check out code
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Cache deb packages
uses: actions/cache@v2
id: cache-debs
with:
path: "~/cache-debs"
key: cache-debs-libbpf-1:0.4.0-1ubuntu1
- name: Install deb packages
env:
CACHE_HIT: ${{steps.cache-debs.outputs.cache-hit}}
LIBBPF_VERSION: "1:0.4.0-1ubuntu1"
run: |
if [[ "$CACHE_HIT" == 'true' ]]; then
sudo cp --verbose --force --recursive ~/cache-debs/* /
else
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:tuxinvader/kernel-build-tools
sudo apt-get update
sudo apt install -y libbpf-dev="$LIBBPF_VERSION"
mkdir -p ~/cache-debs
sudo dpkg -L libbpf-dev | \
while IFS= read -r f; do \
if test -f $f; then echo $f; fi; \
done | xargs cp --parents --target-directory ~/cache-debs/
fi
- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ hashFiles('**/*Dockerfile') }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Login to Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v2
with:
context: connectivity-exporter/base-image
file: connectivity-exporter/base-image/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move Docker layers cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Build
run: |
make -C connectivity-exporter
- name: Test
run: |
make -C connectivity-exporter test
#- name: Setup Minikube
# uses: manusa/[email protected]
# with:
# minikube version: 'v1.9.2'
# kubernetes version: 'v1.18.2'
# github token: ${{ secrets.GITHUB_TOKEN }}