-
Notifications
You must be signed in to change notification settings - Fork 93
161 lines (139 loc) · 7.54 KB
/
pipeline.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Pipeline
on:
push:
paths:
- "src/**"
- ".github/workflows/**"
pull_request:
paths:
- "src/**"
- ".github/workflows/**"
env:
version: 7.1.${{github.run_number}}
imageRepository: "emberstack/kubernetes-reflector"
DOCKER_CLI_EXPERIMENTAL: "enabled"
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: artifacts - prepare directories
run: |
mkdir -p .artifacts/helm
mkdir -p .artifacts/kubectl
- name: helm - import README
run: cp README.md src/helm/reflector/README.md
- name: helm - package chart
run: helm package --destination .artifacts/helm --version ${{env.version}} --app-version ${{env.version}} src/helm/reflector
- name: helm - template chart
run: helm template --namespace kube-system reflector .artifacts/helm/reflector-${{env.version}}.tgz > .artifacts/kubectl/reflector-${{env.version}}.yaml
- name: "artifacts - upload - helm chart"
uses: actions/upload-artifact@v4
with:
name: helm
path: .artifacts/helm
- name: "artifacts - upload - kubectl manifests"
uses: actions/upload-artifact@v4
with:
name: kubectl
path: .artifacts/kubectl
- name: "docker - build PR"
if: github.event_name == 'pull_request'
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name builder --driver docker-container --use
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64 -t ${{env.imageRepository}}:build-${{env.version}}-amd64 -f src/ES.Kubernetes.Reflector/Dockerfile src/
docker buildx build --platform linux/arm -t ${{env.imageRepository}}:build-${{env.version}}-arm32v7 -f src/ES.Kubernetes.Reflector/Dockerfile src/
docker buildx build --platform linux/arm64 -t ${{env.imageRepository}}:build-${{env.version}}-arm64v8 -f src/ES.Kubernetes.Reflector/Dockerfile src/
- name: tools - docker - login
if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
uses: docker/login-action@v3
with:
username: ${{ secrets.ES_DOCKERHUB_USERNAME }}
password: ${{ secrets.ES_DOCKERHUB_PAT }}
- name: "docker - build and publish"
if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name builder --driver docker-container --use
docker buildx inspect --bootstrap
docker buildx build --push --platform linux/amd64 --provenance=false -t ${{env.imageRepository}}:build-${{env.version}}-amd64 -f src/ES.Kubernetes.Reflector/Dockerfile src/
docker buildx build --push --platform linux/arm --provenance=false -t ${{env.imageRepository}}:build-${{env.version}}-arm32v7 -f src/ES.Kubernetes.Reflector/Dockerfile src/
docker buildx build --push --platform linux/arm64 --provenance=false -t ${{env.imageRepository}}:build-${{env.version}}-arm64v8 -f src/ES.Kubernetes.Reflector/Dockerfile src/
docker pull --platform linux/amd64 ${{env.imageRepository}}:build-${{env.version}}-amd64
docker pull --platform linux/arm/v7 ${{env.imageRepository}}:build-${{env.version}}-arm32v7
docker pull --platform linux/arm64 ${{env.imageRepository}}:build-${{env.version}}-arm64v8
docker manifest create ${{env.imageRepository}}:build-${{env.version}} ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8
docker manifest inspect ${{env.imageRepository}}:build-${{env.version}}
docker manifest push ${{env.imageRepository}}:build-${{env.version}}
cd:
name: CD
needs: ci
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: tools - docker - login
uses: docker/login-action@v3
with:
username: ${{ secrets.ES_DOCKERHUB_USERNAME }}
password: ${{ secrets.ES_DOCKERHUB_PAT }}
- name: artifacts - download - helm chart
uses: actions/download-artifact@v4
with:
name: helm
path: .artifacts/helm
- name: artifacts - download - kubectl manifests
uses: actions/download-artifact@v4
with:
name: kubectl
path: .artifacts/kubectl
- name: "docker - tag and push"
run: |
docker pull ${{env.imageRepository}}:build-${{env.version}}-amd64
docker pull ${{env.imageRepository}}:build-${{env.version}}-arm32v7
docker pull ${{env.imageRepository}}:build-${{env.version}}-arm64v8
docker manifest create ${{env.imageRepository}}:${{env.version}} ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8
docker manifest create ${{env.imageRepository}}:latest ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8
docker manifest push ${{env.imageRepository}}:${{env.version}}
docker manifest push ${{env.imageRepository}}:latest
docker manifest push ${{env.imageRepository}}:${{env.version}}
docker manifest push ${{env.imageRepository}}:latest
docker tag ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:${{env.version}}-amd64
docker tag ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:${{env.version}}-arm32v7
docker tag ${{env.imageRepository}}:build-${{env.version}}-arm64v8 ${{env.imageRepository}}:${{env.version}}-arm64v8
docker push ${{env.imageRepository}}:${{env.version}}-amd64
docker push ${{env.imageRepository}}:${{env.version}}-arm32v7
docker push ${{env.imageRepository}}:${{env.version}}-arm64v8
- name: github - checkout - helm-charts
uses: actions/checkout@v4
with:
repository: emberstack/helm-charts
token: ${{ secrets.ES_GITHUB_PAT }}
path: helm-charts
- name: github - publish - chart
run: |
mkdir -p helm-charts/repository/reflector
cp .artifacts/helm/reflector-${{env.version}}.tgz helm-charts/repository/reflector
cd helm-charts
git config user.name "Romeo Dumitrescu"
git config user.email "5931333+winromulus@users.noreply.github.com"
git add .
git status
git commit -m "Added reflector-${{env.version}}.tgz"
git push
- name: github - release - set manifest name
run: |
mkdir -p github
cp .artifacts/kubectl/reflector-${{env.version}}.yaml github/reflector.yaml
- name: github - create release
uses: softprops/action-gh-release@v2
with:
repository: emberstack/kubernetes-reflector
tag_name: v${{env.version}}
body: The release process is automated.
generate_release_notes: true
token: ${{ secrets.ES_GITHUB_PAT }}
files: |
github/reflector.yaml