-
Notifications
You must be signed in to change notification settings - Fork 36
109 lines (92 loc) · 2.84 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
name: CI
on:
pull_request:
push:
branches:
- main
env:
CGO_ENABLED: 0
GO_VERSION: '1.21'
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
name: "Validate ${{ matrix.target }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["verify", "lint", "test"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- uses: actions/cache@v4
with:
path: hack/tools/bin
key: ${{ runner.os }}-tools-bin-${{ matrix.target }}-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-tools-bin-${{ matrix.target }}-
${{ runner.os }}-tools-bin-
- uses: actions/cache@v4
if: ${{ matrix.target == 'test' }}
with:
path: /tmp/kubebuilder-tools-*.tar.gz
key: ${{ runner.os }}-tmp-${{ matrix.target }}-${{ hashFiles('scripts/fetch_ext_bins.sh') }}
restore-keys: |
${{ runner.os }}-tmp-${{ matrix.target }}-
${{ runner.os }}-tmp-
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}
codespell:
name: Codespell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/[email protected]
with:
check_filenames: true
check_hidden: true
skip: "./.git,./go.mod,./go.sum"
ignore_words_list: ro
build-and-push-image:
name: Build and push manager image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ github.event_name != 'pull_request' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}