Skip to content

Commit a04cba8

Browse files
feat: this commit introduces ci/cd workflows for production deployment, package publishing, and quality assurance
1 parent 985becb commit a04cba8

6 files changed

Lines changed: 257 additions & 1 deletion
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: workflow — trigger federation production deployment
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
federation_backend: ${{ steps.filter.outputs.federation_backend }}
12+
federation_proxy: ${{ steps.filter.outputs.federation_proxy }}
13+
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v4
17+
18+
- name: detect changed paths
19+
id: filter
20+
uses: dorny/paths-filter@v4
21+
with:
22+
filters: |
23+
federation_backend:
24+
- 'Applications/Backend/**'
25+
federation_proxy:
26+
- 'Applications/Proxy/**'
27+
28+
deploy-federation-backend:
29+
needs: changes
30+
if: needs.changes.outputs.federation_backend == 'true'
31+
uses: ./.github/workflows/template-deployment.yml
32+
with:
33+
service_path: Applications/Backend
34+
image_name: httpsrichardy/federation
35+
deploy_url_secret: BACKEND_PRODUCTION_DEPLOY_WEBHOOK_URL
36+
secrets: inherit
37+
38+
deploy-federation-proxy:
39+
needs: changes
40+
if: needs.changes.outputs.federation_proxy == 'true'
41+
uses: ./.github/workflows/template-deployment.yml
42+
with:
43+
service_path: Applications/Proxy
44+
image_name: httpsrichardy/federation.proxy
45+
deploy_url_secret: PROXY_PRODUCTION_DEPLOY_WEBHOOK_URL
46+
secrets: inherit
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: pipeline ci/cd - publish federation package
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'Packages/Federation.Sdk/**'
9+
- 'Packages/Federation.Sdk.Contracts/**'
10+
11+
jobs:
12+
changes:
13+
runs-on: ubuntu-latest
14+
15+
outputs:
16+
federation_sdk: ${{ steps.filter.outputs.federation_sdk }}
17+
federation_sdk_contracts: ${{ steps.filter.outputs.federation_sdk_contracts }}
18+
19+
steps:
20+
- name: checkout code
21+
uses: actions/checkout@v5
22+
with:
23+
fetch-depth: 0
24+
25+
- name: detect changed paths
26+
id: filter
27+
uses: dorny/paths-filter@v4
28+
with:
29+
filters: |
30+
federation_sdk:
31+
- 'Packages/Federation.Sdk/**'
32+
federation_sdk_contracts:
33+
- 'Packages/Federation.Sdk.Contracts/**'
34+
35+
# publish this package if there are changes in the corresponding path
36+
publish-federation-sdk:
37+
needs: changes
38+
if: needs.changes.outputs.federation_sdk == 'true'
39+
uses: ./.github/workflows/template-publish-package.yml
40+
with:
41+
working_directory: Packages/Federation.Sdk/Source
42+
dotnet_version: 9.0.x
43+
base_version: "1.0"
44+
secrets: inherit
45+
46+
# publish this package if there are changes in the corresponding path
47+
publish-federation-sdk-contracts:
48+
needs: changes
49+
if: needs.changes.outputs.federation_sdk_contracts == 'true'
50+
uses: ./.github/workflows/template-publish-package.yml
51+
with:
52+
working_directory: Packages/Federation.Sdk.Contracts/Source
53+
dotnet_version: 9.0.x
54+
base_version: "1.0"
55+
secrets: inherit

.github/workflows/quality-assurance-pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: pipeline ci/cd — trigger pull request quality assurance
33
on:
44
pull_request:
55
branches:
6-
- main
6+
- master
77

88
jobs:
99
changes:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: pipeline ci/cd — trigger deployment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
service_path:
7+
required: true
8+
type: string
9+
10+
image_name:
11+
required: true
12+
type: string
13+
14+
deploy_url_secret:
15+
required: true
16+
type: string
17+
18+
jobs:
19+
deploy:
20+
runs-on: ubuntu-latest
21+
22+
defaults:
23+
run:
24+
working-directory: ${{ inputs.service_path }}
25+
26+
steps:
27+
- name: checkout
28+
uses: actions/checkout@v4
29+
30+
- name: build docker image
31+
run: docker build -t ${{ inputs.image_name }}:latest -t ${{ inputs.image_name }}:${{ github.run_number }}.0.0 .
32+
33+
- name: login docker hub
34+
uses: docker/login-action@v3
35+
with:
36+
username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
password: ${{ secrets.DOCKERHUB_TOKEN }}
38+
39+
- name: push docker image
40+
run: |
41+
docker push ${{ inputs.image_name }}:latest
42+
docker push ${{ inputs.image_name }}:${{ github.run_number }}.0.0
43+
44+
- name: deploy webhook
45+
run: curl -X POST ${{ secrets[inputs.deploy_url_secret] }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: pipeline ci/cd - publish federation package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
working_directory:
7+
description: project directory to restore/build/pack
8+
required: true
9+
type: string
10+
11+
dotnet_version:
12+
description: .NET SDK version
13+
required: false
14+
type: string
15+
default: 9.0.x
16+
17+
base_version:
18+
description: base semantic version
19+
required: false
20+
type: string
21+
default: "1.0"
22+
23+
publish_package:
24+
description: if false, runs restore/build/pack without pushing
25+
required: false
26+
type: boolean
27+
default: true
28+
secrets:
29+
NUGET_API_KEY:
30+
required: true
31+
32+
jobs:
33+
publish:
34+
runs-on: ubuntu-latest
35+
36+
defaults:
37+
run:
38+
working-directory: ${{ inputs.working_directory }}
39+
40+
steps:
41+
- name: checkout code
42+
uses: actions/checkout@v5
43+
44+
- name: setup .NET
45+
uses: actions/setup-dotnet@v4
46+
with:
47+
dotnet-version: ${{ inputs.dotnet_version }}
48+
49+
- name: restore dependencies
50+
run: dotnet restore
51+
52+
- name: build
53+
run: dotnet build --configuration Release --no-restore
54+
55+
- name: test
56+
run: dotnet test --configuration Release --no-restore --no-build
57+
58+
- name: set version and pack
59+
id: pack
60+
env:
61+
BASE_VERSION: ${{ inputs.base_version }}
62+
run: |
63+
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
64+
VERSION="${BASE_VERSION}.${GITHUB_RUN_NUMBER}"
65+
else
66+
VERSION="${BASE_VERSION}-beta.${GITHUB_RUN_NUMBER}"
67+
fi
68+
69+
echo "use version: $VERSION"
70+
dotnet pack -c Release -p:PackageVersion=$VERSION -o ./output --no-build
71+
72+
echo "package_version=$VERSION" >> $GITHUB_OUTPUT
73+
74+
- name: push package to nuget
75+
if: ${{ inputs.publish_package }}
76+
run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: pipeline ci/cd — quality assurance
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
service_path:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
quality-assurance:
12+
runs-on: ubuntu-latest
13+
14+
defaults:
15+
run:
16+
working-directory: ${{ inputs.service_path }}
17+
18+
steps:
19+
- name: checkout
20+
uses: actions/checkout@v5
21+
22+
- name: setup dotnet
23+
uses: actions/setup-dotnet@v4
24+
with:
25+
dotnet-version: '9.0.x'
26+
27+
- name: restore
28+
run: dotnet restore
29+
30+
- name: build
31+
run: dotnet build --no-restore --configuration Release
32+
33+
- name: test
34+
run: dotnet test --no-build --configuration Release --verbosity normal

0 commit comments

Comments
 (0)