11on :
22 push :
33 branches :
4- - master
5- - develop
4+ - ' **'
65 pull_request :
76 branches :
8- - master
9- - develop
7+ - ' **'
108 types : [ opened, reopened, synchronize ]
119 workflow_call :
1210 workflow_dispatch :
@@ -15,11 +13,42 @@ name: ci-build
1513
1614env :
1715 REGISTRY : ghcr.io
16+ DOTNET_VERSION : 10.0.x
1817
1918jobs :
2019
20+ tests :
21+ name : Tests (${{ matrix.name }})
22+ runs-on : ubuntu-latest
23+ strategy :
24+ fail-fast : false
25+ matrix :
26+ include :
27+ - name : common-unit
28+ project : DesktopRepositoryServer.Tests/DesktopRepositoryServer.Tests.csproj
29+
30+ steps :
31+ - name : Checkout
32+ uses : actions/checkout@v5
33+
34+ - uses : actions/setup-dotnet@v5
35+ with :
36+ dotnet-version : ' ${{ env.DOTNET_VERSION }}'
37+
38+ - name : Run ${{ matrix.name }} tests
39+ run : |
40+ set -euo pipefail
41+ dotnet test -c Release ${{ matrix.project }}
42+
2143 build :
44+ name : Build (${{ matrix.image }})
2245 runs-on : ubuntu-latest
46+ strategy :
47+ fail-fast : false
48+ matrix :
49+ include :
50+ - dockerfile : docker/API.Dockerfile
51+ image : desktop-repository-server
2352
2453 steps :
2554 - name : Checkout
@@ -35,44 +64,57 @@ jobs:
3564 username : ${{ github.actor }}
3665 password : ${{ secrets.GITHUB_TOKEN }}
3766
38- - name : Extract metadata (tags, labels) for Docker
39- id : meta
40- uses : docker/metadata-action@v5
67+ - name : Build ${{ matrix.image }}
68+ uses : ./.github/actions/build-app
69+ with :
70+ dockerfile : ${{ matrix.dockerfile }}
71+ push : ${{ inputs.push || (github.ref_protected && github.event_name != 'pull_request') }}
72+ image : ${{ matrix.image }}
73+ platforms : ${{ inputs.platforms || 'linux/amd64' }}
74+ tag-prefix : ${{ inputs.tag-prefix || 'rn' }}
75+
76+ promote-image :
77+ name : Promote Image (${{ matrix.image }})
78+ needs : [build, tests]
79+ runs-on : ubuntu-latest
80+ if : ${{ inputs.push || (github.ref_protected && github.event_name != 'pull_request') }}
81+ strategy :
82+ fail-fast : false
83+ matrix :
84+ include :
85+ - image : desktop-repository-server
86+
87+ steps :
88+ - name : Checkout
89+ uses : actions/checkout@v5
90+
91+ - name : Log in to Container Registry
92+ uses : docker/login-action@v3
4193 with :
42- images : ${{ env.REGISTRY }}/${{ github.repository_owner }}/desktop-repository-server
43- flavor : |
44- latest=false
45- tags : |
46- type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
47- type=ref,event=branch
48- type=ref,event=pr
94+ registry : ${{ env.REGISTRY }}
95+ username : ${{ github.actor }}
96+ password : ${{ secrets.GITHUB_TOKEN }}
4997
50- - name : Build and push
51- uses : docker/build-push-action@v6
98+ - name : Promote Manifest ${{ matrix.image }}
99+ uses : ./.github/actions/promote-image
52100 with :
53- context : .
54- file : Dockerfile
55- push : ${{ github.event_name != 'pull_request' }}
56- tags : ${{ steps.meta.outputs.tags }}
57- labels : ${{ steps.meta.outputs.labels }}
58- platforms : linux/amd64,linux/arm64
101+ image : ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image }}
102+ run-tag : ${{ inputs.tag-prefix || 'rn' }}-${{ github.run_number }}-a${{ github.run_attempt }}
103+ latest : ${{ inputs.latest || false }}
59104
60- deploy-production :
105+ deploy-prod-workflow :
61106 runs-on : ubuntu-latest
62- needs : build
63- if : ${{ github.repository_owner == 'OpenShock' && github. ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'master' }}
107+ needs : promote-image
108+ if : ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'master' }}
64109 environment : production
65-
66110 steps :
67- - uses : actions/checkout@v5
68- with :
69- sparse-checkout : |
70- .github
71-
72- - uses : ./.github/actions/kubernetes-rollout-restart
111+ - name : Send repository dispatch
112+ uses : peter-evans/repository-dispatch@v4
73113 with :
74- apiurl : ${{ secrets.KUBERNETES_APIURL }}
75- token : ${{ secrets.KUBERNETES_TOKEN }}
76- deployments : ${{ vars.DEPLOYMENT_NAMES }}
77- ts-oauth-client-id : ${{ secrets.TS_OAUTH_CLIENT_ID }}
78- ts-oauth-secret : ${{ secrets.TS_OAUTH_SECRET }}
114+ token : ${{ secrets.GITOPS_PAT }}
115+ repository : openshock/kubernetes-cluster-gitops
116+ event-type : update-desktop-repository-server-prod
117+ client-payload : |
118+ {
119+ "tag": "${{ inputs.tag-prefix || 'rn' }}-${{ github.run_number }}-a${{ github.run_attempt }}"
120+ }
0 commit comments