-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
100 lines (90 loc) · 2.85 KB
/
Taskfile.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
---
version: 3
vars:
PROJECT_NAME:
sh: echo ${PWD##*/}
MODULE: github.com/{{ .GROUP }}/{{ .PROJECT_NAME }}
#REGISTRY: eu.gcr.io
REPOSITORY_NAME: "{{ .PROJECT_NAME }}"
REGISTRY: scr.cd43.sthings-pve.labul.sva.de
GROUP: stuttgart-things
DATE:
sh: date +"%y.%m%d.%H%M"
BRANCH:
sh: if [ $(git rev-parse --abbrev-ref HEAD) != "main" ]; then echo $(git rev-parse --abbrev-ref HEAD) ; fi
CONTROLLER_GEN_CMD: "./bin/controller-gen"
KUSTOMIZE_CMD: kustomize
CONTAINER_RUNTIME_CMD: nerdctl
CRD_DIR: config/crd/bases
MANIFEST_DIR: ./deploy
tasks:
manifests:
desc: Generate manifests w/ kustomize
deps: [image]
cmds:
- task: crds
- cd config/manager && {{ .KUSTOMIZE_CMD }} edit set image controller={{ .REGISTRY }}/{{ .REPOSITORY_NAME }}/{{ lower (.PROJECT_NAME) }}:{{ .DATE }}
- '{{ .KUSTOMIZE_CMD }} build config/default > {{ .MANIFEST_DIR }}/manifests.yaml'
apply:
desc: Deploy manifests
deps: [manifests]
cmds:
# - kubectl get nodes
- kubectl apply -f {{ .MANIFEST_DIR }}/clusterrole.yaml
- kubectl apply -f {{ .MANIFEST_DIR }}/manifests.yaml
crds:
desc: Generate crds
deps: [lint]
cmds:
- '{{ .CONTROLLER_GEN_CMD }} rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config={{ .CRD_DIR }}'
branch:
desc: Create branch from main
cmds:
- git checkout main
- git branch
- git pull
- |
echo "Enter to be created (remote) branch:"
read BRANCH_NAME;
git checkout -b ${BRANCH_NAME}
git push origin ${BRANCH_NAME}
- git branch
- git branch --set-upstream-to=origin/main ${BRANCH_NAME}
commit:
desc: Commit + push code into branch
cmds:
- git pull
- |
echo "ENTER COMMIT MESSAGE"
read COMMIT_MESSAGE;
git add *
git commit -am "$(echo ${COMMIT_MESSAGE})"
git push origin -u {{ .BRANCH }}
pr:
desc: Create pull request into main
cmds:
- task: commit
- gh pr create -t "{{ .BRANCH }}" -b "{{ .BRANCH }} branch into main"
- sleep 20s
- gh pr checks $(gh pr list | grep "^[^#;]" | awk '{print $1}') --watch
- gh pr merge $(gh pr list | grep "^[^#;]" | awk '{print $1}') --auto --rebase --delete-branch
- git checkout main && git pull
lint:
desc: Lint code
cmds:
- cmd: golangci-lint run
ignore_error: true
build:
desc: Build code
deps: [lint]
cmds:
- make generate
- make manifests
- go mod tidy
- go install
image:
desc: Build container image
deps: [build]
cmds:
- sudo {{ .CONTAINER_RUNTIME_CMD }} build -t {{ .REGISTRY }}/{{ .REPOSITORY_NAME }}/{{ lower (.PROJECT_NAME) }}:{{ .DATE }} .
- sudo {{ .CONTAINER_RUNTIME_CMD }} push {{ .REGISTRY }}/{{ .REPOSITORY_NAME }}/{{ lower (.PROJECT_NAME) }}:{{ .DATE }}