-
-
Notifications
You must be signed in to change notification settings - Fork 11
160 lines (143 loc) · 6.22 KB
/
ci.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
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
name: CI
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
workflow_dispatch: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4
with:
dotnet-version: '9.0.x'
- name: Set variables
id: variables
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo VERSION=$VERSION >> $GITHUB_OUTPUT
- name: Test project
run: |
dotnet test ./TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj
- name: Build project
run: |
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime linux-x64 --output ./output/TeslaMateAgile-linux-x64
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime linux-arm64 --output ./output/TeslaMateAgile-linux-arm64
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime linux-arm --output ./output/TeslaMateAgile-linux-arm
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime win-x64 --output ./output/TeslaMateAgile-win-x64
- name: Build Docker images
run: |
for appname in TeslaMateAgile; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Building $appname docker amd64"
docker build -t $app:amd64 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-amd64
echo "Building $appname docker arm32v7"
docker build -t $app:arm32v7 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-arm32v7
echo "Building $appname docker arm64v8"
docker build -t $app:arm64v8 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-arm64v8
done
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-linux-x64
path: ./output/TeslaMateAgile-linux-x64
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-linux-arm64
path: ./output/TeslaMateAgile-linux-arm64
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-linux-arm
path: ./output/TeslaMateAgile-linux-arm
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-win-x64
path: ./output/TeslaMateAgile-win-x64
- name: Push Docker images
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
for appname in TeslaMateAgile; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Deploying $appname"
for arch in amd64 arm32v7 arm64v8; do
docker tag $app:$arch $DOCKER_USERNAME/$app:latest-$arch
docker tag $app:$arch $DOCKER_USERNAME/$app:$VERSION-$arch
done
versions=($VERSION)
if [[ $VERSION =~ "-" ]]; then
echo "Pre-release version detected, not setting latest tag"
else
versions+=("latest")
echo "Adding latest tag"
fi
for ver in "${versions[@]}"; do
echo "Deploying version $ver"
for arch in amd64 arm32v7 arm64v8; do
echo "Pushing docker tag $ver-arch"
docker push $DOCKER_USERNAME/$app:$ver-$arch
done
docker manifest create $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-amd64 $DOCKER_USERNAME/$app:$ver-arm32v7 $DOCKER_USERNAME/$app:$ver-arm64v8
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-amd64 --os linux --arch amd64
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-arm32v7 --os linux --arch arm
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-arm64v8 --os linux --arch arm64
docker manifest push $DOCKER_USERNAME/$app:$ver
done
done
env:
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_CLI_EXPERIMENTAL: enabled
VERSION: ${{ steps.variables.outputs.VERSION }}
if: startsWith(github.ref, 'refs/tags/')
- name: Zip project
run: |
cd ./output/TeslaMateAgile-linux-x64
zip -r ../TeslaMateAgile-linux-x64.zip .
cd ../TeslaMateAgile-linux-arm64
zip -r ../TeslaMateAgile-linux-arm64.zip .
cd ../TeslaMateAgile-linux-arm
zip -r ../TeslaMateAgile-linux-arm.zip .
cd ../TeslaMateAgile-win-x64
zip -r ../TeslaMateAgile-win-x64.zip .
cd ../../
if: startsWith(github.ref, 'refs/tags/')
- name: Create Release
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2
with:
name: Release ${{ github.ref_name }}
draft: true
prerelease: false
files: output/*.zip
if: startsWith(github.ref, 'refs/tags/')
deploy:
if: github.event_name != 'pull_request'
name: Deploy
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Azure Login
uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Login to Kubernetes
uses: Azure/aks-set-context@4edaee69f820359371ee8bc85189ac03a21d3a58 # v3
with:
resource-group: abyss
cluster-name: abyss
- run: echo "${{ secrets.ABYSS_VALUES_FILE }}" | base64 --decode > abyss.values.yaml
- name: Install TeslaMateAgile
run: |
helm upgrade --install --wait --atomic \
teslamateagile ./charts/teslamateagile \
--namespace default \
--values abyss.values.yaml