-
Notifications
You must be signed in to change notification settings - Fork 51
144 lines (141 loc) · 5.18 KB
/
ci.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
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
on:
pull_request: {}
push:
branches:
- main
jobs:
get-changed-files:
name: Get Changed Files
runs-on: ubuntu-20.04
outputs:
changed-files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
control-plane-changed: ${{ steps.control-plane-changed.outputs.any_modified }}
dataplane-changed: ${{ steps.dataplane-changed.outputs.any_modified }}
workflow-changed: ${{ steps.workflow-changed.outputs.any_modified }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- name: Get list of all changes
uses: tj-actions/changed-files@1d6e210c970d01a876fbc6155212d068e79ca584
id: changed-files
- name: Check if any files related to the building of the control plane image have changed (see the Dockerfiles)
uses: tj-actions/changed-files@1d6e210c970d01a876fbc6155212d068e79ca584
id: control-plane-changed
with:
files: |
Dockerfile
go.mod
go.sum
main.go
controllers/
LICENSE
- name: Check if any files related to the building of the dataplane image have changed (see the Dockerfiles)
uses: tj-actions/changed-files@1d6e210c970d01a876fbc6155212d068e79ca584
id: dataplane-changed
with:
files: |
dataplane/Dockerfile
dataplane/go.mod
dataplane/go.sum
dataplane/main.go
dataplane/xdp.c
dataplane/Makefile
dataplane/LICENCE
- name: Check if any of the workflow files have changed
uses: tj-actions/changed-files@1d6e210c970d01a876fbc6155212d068e79ca584
id: workflow-changed
with:
files: |
.github/workflows/
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file"
done
pr-docker-build:
name: PR Docker build
needs: [ get-changed-files ]
if: >-
github.event_name == 'pull_request'
&& (
needs.get-changed-files.outputs.control-plane-changed == 'true'
|| needs.get-changed-files.outputs.dataplane-changed == 'true'
|| needs.get-changed-files.outputs.workflow-changed == 'true'
)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c74574e6c82eeedc46366be1b0d287eff9085eb6
with:
install: true
- name: Docker build - Control Plane
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: kong/blixt-controlplane:pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
outputs: type=docker,dest=/tmp/blixt-controlplane.tar
- name: Upload Image Artifact - Control Plane
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
with:
name: blixt-controlplane
path: /tmp/blixt-controlplane.tar
- name: Docker build - Dataplane
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5
with:
context: dataplane
cache-from: type=gha
cache-to: type=gha,mode=max
tags: kong/blixt-dataplane:pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
outputs: type=docker,dest=/tmp/blixt-dataplane.tar
- name: Upload Image Artifact - Dataplane
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
with:
name: blixt-dataplane
path: /tmp/blixt-dataplane.tar
main-docker-build:
name: Main branch Docker build
needs: [ get-changed-files ]
if: >-
github.event_name == 'push'
&& (
needs.get-changed-files.outputs.control-plane-changed == 'true'
|| needs.get-changed-files.outputs.dataplane-changed == 'true'
|| needs.get-changed-files.outputs.workflow-changed == 'true'
)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c74574e6c82eeedc46366be1b0d287eff9085eb6
with:
install: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build - Control Plane
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/kong/blixt-controlplane:latest
- name: Docker build - Data Plane
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5
with:
context: dataplane
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/kong/blixt-dataplane:latest