1
+ name : CI and Docker Deploy
2
+
3
+ on :
4
+ push :
5
+ branches : ['main', 'dev']
6
+ tags : ['v*.*.*']
7
+ pull_request :
8
+ branches : ['dev']
9
+
10
+ env :
11
+ # github.repository as <account>/<repo>
12
+ IMAGE_NAME : mnestix-proxy
13
+ # Update the version manually
14
+ IMAGE_TAG_VERSION : 0.1.0
15
+
16
+ jobs :
17
+ run-tests :
18
+ name : Integration tests
19
+ runs-on : ubuntu-latest
20
+ permissions :
21
+ contents : read
22
+
23
+ steps :
24
+ - name : Checkout repository
25
+ uses : actions/checkout@v4
26
+
27
+ - name : Setup .NET
28
+ uses : actions/setup-dotnet@v4
29
+ with :
30
+ dotnet-version : ' 8.0.x'
31
+
32
+ - name : Restore dependencies
33
+ run : dotnet restore
34
+
35
+ - name : Build solution
36
+ run : dotnet build --no-restore --configuration Release
37
+
38
+ - name : Run tests
39
+ run : dotnet test --no-build --verbosity normal --configuration Release
40
+
41
+ docker-build :
42
+ name : Build images and push
43
+ needs : run-tests
44
+ runs-on : ubuntu-latest
45
+ if : github.event_name != 'pull_request' && github.repository_owner == 'eclipse-mnestix' &&
46
+ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
47
+ permissions :
48
+ contents : read
49
+
50
+ steps :
51
+ - name : Checkout code
52
+ uses : actions/checkout@v4
53
+
54
+ - name : Set up Docker Buildx
55
+ uses : docker/setup-buildx-action@v3
56
+
57
+ - name : Login to DockerHub
58
+ uses : docker/login-action@v3
59
+ with :
60
+ username : ${{ secrets.DOCKER_USERNAME }}
61
+ password : ${{ secrets.DOCKER_API_TOKEN }}
62
+
63
+ - name : Extract branch name
64
+ id : extract_branch
65
+ run : echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
66
+
67
+ - name : Build and push Docker image
68
+ uses : docker/build-push-action@v6
69
+ with :
70
+ context : " ."
71
+ push : true
72
+ platforms : linux/amd64,linux/arm64
73
+ tags : |
74
+ ${{ github.ref == 'refs/heads/main' && format('mnestix/{0}:{1}', env.IMAGE_NAME, env.IMAGE_TAG_VERSION) || '' }}
75
+ ${{ github.ref == 'refs/heads/main' && format('mnestix/{0}:latest', env.IMAGE_NAME) || '' }}
76
+ ${{ github.ref != 'refs/heads/main' && format('mnestix/{0}:{1}', env.IMAGE_NAME, steps.extract_branch.outputs.branch) || '' }}
0 commit comments