forked from alibaba/kubeskoop
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (87 loc) · 3.01 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
name: build
on:
push:
branches: [main]
tags:
- 'v*'
pull_request:
branches: [main]
env:
REGISTRY: docker.io
OWNER: kubeskoop
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
jobs:
build-skoop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta agent
id: meta-agent
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/agent
tags: |
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Docker meta controller
id: meta-controller
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/controller
tags: |
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
if: ${{ github.event_name != 'pull_request' && github.event.action != 'unassigned' }}
- name: Go Build Cache for Docker
uses: actions/cache@v3
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
- name: inject go-build-cache into docker
# v1 was composed of two actions: "inject" and "extract".
# v2 is unified to a single action.
uses: reproducible-containers/[email protected]
with:
cache-source: go-build-cache
- name: Build and push agent
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-agent.outputs.tags }}
target: agent
labels: ${{ steps.meta-agent.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push controller
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-controller.outputs.tags }}
target: controller
labels: ${{ steps.meta-controller.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max