Skip to content

Commit 7ae366a

Browse files
authored
Feature/GitHub monitor cicd (#93)
2 parents 2c14d76 + d83a385 commit 7ae366a

File tree

107 files changed

+292
-523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+292
-523
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy AHK.GitHub.Monitor
2+
3+
on:
4+
# Trigger the workflow on a push to the main branch.
5+
push:
6+
branches: dev
7+
8+
# Allows you to run this workflow manually (for any branch) from the Actions tab.
9+
workflow_dispatch:
10+
11+
env:
12+
artifactName: buildArtifact
13+
appNameEnvVar: "AHK_GitHub_Monitor_App_Name"
14+
publishProfileSecret: "AHK_GitHub_Monitor_PUBLISH_PROFILE"
15+
packageName: "Ahk.GitHub.Monitor"
16+
17+
jobs:
18+
# 👇 Call the build workflow to create the artifacts to deploy, and provide the artifact name.
19+
build:
20+
uses: ./.github/workflows/AHK.GitHub.Monitor-build.yml
21+
with:
22+
artifactName: ${{ github.env.artifactName }}
23+
secrets: inherit # Pass secrets to the build workflow, if necessary.
24+
25+
deploy-to-test:
26+
needs: build
27+
uses: ./.github/workflows/AzureFunctions-deploy.template.yml
28+
with:
29+
environmentName: test
30+
artifactName: ${{ github.env.artifactName }}
31+
packageName: ${{ github.env.packageName }}
32+
appNameEnvVar: ${{ github.env.appNameEnvVar }}
33+
publishProfileSecret: ${{ github.env.publishProfileSecret }}
34+
secrets: inherit # Pass repository secrets to the deployment workflow.
35+
36+
deploy-to-production:
37+
needs: deploy-to-test
38+
uses: ./.github/workflows/AzureFunctions-deploy.template.yml
39+
with:
40+
environmentName: production
41+
artifactName: ${{ github.env.artifactName }}
42+
packageName: ${{ github.env.packageName }}
43+
appNameEnvVar: ${{ github.env.appNameEnvVar }}
44+
publishProfileSecret: ${{ github.env.publishProfileSecret }}
45+
secrets: inherit # Pass repository secrets to the deployment workflow.

.github/workflows/AHK.GradeManagement-deploy.template.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
description: The name of the environment to deploy to.
1313
required: true
1414
type: string
15-
1615

1716
jobs:
1817
deploy:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build AHK.GradeManagement.QueueFunction
2+
3+
on:
4+
pull_request:
5+
branches: dev # Run workflow on PRs to the main branch.
6+
7+
# Run workflow on pushes to any branch, except the main branch.
8+
# push:
9+
# branches-ignore: dev
10+
11+
# Allows you to run this workflow manually from the Actions tab.
12+
workflow_dispatch:
13+
14+
# 👇 Allows this workflow to be called from the deployment workflow, but the parameters must be provided.
15+
workflow_call:
16+
inputs:
17+
artifactName:
18+
description: The name of the artifact to upload to.
19+
required: true
20+
type: string
21+
22+
env:
23+
# 👇 Provide a default artifact name for when this workflow is not called by the deployment workflow.
24+
artifactName: ${{ inputs.artifactName || 'buildArtifact' }}
25+
26+
jobs:
27+
build-and-test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout the repo source code
31+
uses: actions/checkout@v3
32+
33+
- name: Setup dotnet
34+
uses: actions/setup-dotnet@v1
35+
with:
36+
dotnet-version: "9.0.x"
37+
38+
- name: "Run dotnet restore"
39+
working-directory: src/Ahk.GradeManagement
40+
run: dotnet restore Ahk.GradeManagement.sln
41+
42+
- name: "Run dotnet publish"
43+
working-directory: src/Ahk.GradeManagement
44+
run: dotnet publish Ahk.GradeManagement.QueueFunction/Ahk.GradeManagement.QueueFunction.csproj --no-restore --configuration Release --output '${{ github.workspace }}/output/Ahk.GradeManagement.QueueFunction'
45+
46+
- name: Upload artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: ${{ env.artifactName }}
50+
path: ./output # Put the path to the build artifact files directory here.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy AHK.GradeManagement.QueueFunction
2+
3+
on:
4+
# Trigger the workflow on a push to the main branch.
5+
push:
6+
branches: dev
7+
8+
# Allows you to run this workflow manually (for any branch) from the Actions tab.
9+
workflow_dispatch:
10+
11+
env:
12+
artifactName: buildArtifact
13+
appNameEnvVar: "AHK_GradeManagement_QueueFunction_App_Name"
14+
publishProfileSecret: "AHK_GradeManagement_QueueFunction_PUBLISH_PROFILE"
15+
packageName: "Ahk.GradeManagement.QueueFunction"
16+
17+
jobs:
18+
# 👇 Call the build workflow to create the artifacts to deploy, and provide the artifact name.
19+
build:
20+
uses: ./.github/workflows/AHK.GradeManagement.QueueFunction-build.yml
21+
with:
22+
artifactName: ${{ github.env.artifactName }}
23+
secrets: inherit # Pass secrets to the build workflow, if necessary.
24+
25+
deploy-to-test:
26+
needs: build
27+
uses: ./.github/workflows/AzureFunctions-deploy.template.yml
28+
with:
29+
environmentName: test
30+
artifactName: ${{ github.env.artifactName }}
31+
packageName: ${{ github.env.packageName }}
32+
appNameEnvVar: ${{ github.env.appNameEnvVar }}
33+
publishProfileSecret: ${{ github.env.publishProfileSecret }}
34+
secrets: inherit # Pass repository secrets to the deployment workflow.
35+
36+
deploy-to-production:
37+
needs: deploy-to-test
38+
uses: ./.github/workflows/AzureFunctions-deploy.template.yml
39+
with:
40+
environmentName: production
41+
artifactName: ${{ github.env.artifactName }}
42+
packageName: ${{ github.env.packageName }}
43+
appNameEnvVar: ${{ github.env.appNameEnvVar }}
44+
publishProfileSecret: ${{ github.env.publishProfileSecret }}
45+
secrets: inherit # Pass repository secrets to the deployment workflow.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build AHK.GitHub.Monitor
2+
3+
on:
4+
pull_request:
5+
branches: dev # Run workflow on PRs to the main branch.
6+
7+
# Run workflow on pushes to any branch, except the main branch.
8+
# push:
9+
# branches-ignore: dev
10+
11+
# Allows you to run this workflow manually from the Actions tab.
12+
workflow_dispatch:
13+
14+
# 👇 Allows this workflow to be called from the deployment workflow, but the parameters must be provided.
15+
workflow_call:
16+
inputs:
17+
artifactName:
18+
description: The name of the artifact to upload to.
19+
required: true
20+
type: string
21+
22+
env:
23+
# 👇 Provide a default artifact name for when this workflow is not called by the deployment workflow.
24+
artifactName: ${{ inputs.artifactName || 'buildArtifact' }}
25+
26+
jobs:
27+
build-and-test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout the repo source code
31+
uses: actions/checkout@v3
32+
33+
- name: Setup dotnet
34+
uses: actions/setup-dotnet@v1
35+
with:
36+
dotnet-version: "9.0.x"
37+
38+
- name: "Run dotnet restore"
39+
working-directory: src/Ahk.GitHub.Monitor
40+
run: dotnet restore Ahk.GitHub.Monitor.sln
41+
42+
- name: "Run dotnet build"
43+
working-directory: src/Ahk.GitHub.Monitor
44+
run: dotnet build Ahk.GitHub.Monitor.sln --no-restore --configuration Release
45+
46+
- name: "Run dotnet test"
47+
working-directory: src/Ahk.GitHub.Monitor
48+
run: dotnet test Ahk.GitHub.Monitor.sln --no-restore --no-build --configuration Release
49+
50+
- name: "Run dotnet publish"
51+
working-directory: src/Ahk.GitHub.Monitor
52+
run: dotnet publish Ahk.GitHub.Monitor/Ahk.GitHub.Monitor.csproj --no-restore --configuration Release --output '${{ github.workspace }}/output/Ahk.GitHub.Monitor'
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: ${{ env.artifactName }}
58+
path: ./output
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Deploy Functions TEMPLATE
2+
3+
on:
4+
# Allows this workflow to be called from the deployment workflow, but the parameters must be provided.
5+
workflow_call:
6+
inputs:
7+
artifactName:
8+
description: The name of the artifact to download and deploy.
9+
required: true
10+
type: string
11+
environmentName:
12+
description: The name of the environment to deploy to.
13+
required: true
14+
type: string
15+
packageName:
16+
description: The name of the package from the artifact to deploy.
17+
required: true
18+
type: string
19+
20+
jobs:
21+
deploy:
22+
runs-on: ubuntu-latest
23+
environment: ${{ inputs.environmentName }}
24+
steps:
25+
- name: Download artifact
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: ${{ inputs.artifactName }}
29+
path: .
30+
31+
- name: "Run Azure Functions deploy action using publish profile credentials"
32+
uses: Azure/functions-action@v1
33+
id: fa
34+
with:
35+
app-name: ${{ vars[inputs.appName] || env[inputs.appName] }}
36+
publish-profile: ${{ secrets[inputs.publishProfileSecret] }}
37+
package: './${{ inputs.artifactName }}/${{ inputs.packageName }}'

0 commit comments

Comments
 (0)