Skip to content

Commit fd3f8ab

Browse files
committed
function CD workflows
1 parent 652dd51 commit fd3f8ab

6 files changed

+117
-10
lines changed

.github/workflows/AHK.GitHub.Monitor-deploy.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010

1111
env:
1212
artifactName: buildArtifact
13+
appNameEnvVar: "AHK_GitHub_Monitor_App_Name"
14+
publishProfileSecret: "AHK_GitHub_Monitor_PUBLISH_PROFILE"
15+
packageName: "Ahk.GitHub.Monitor"
1316

1417
jobs:
1518
# 👇 Call the build workflow to create the artifacts to deploy, and provide the artifact name.
@@ -21,16 +24,22 @@ jobs:
2124

2225
deploy-to-test:
2326
needs: build
24-
uses: ./.github/workflows/AHK.GitHub.Monitor-deploy.template.yml
27+
uses: ./.github/workflows/AzureFunctions-deploy.template.yml
2528
with:
26-
artifactName: ${{ github.env.artifactName }}
2729
environmentName: test
30+
artifactName: ${{ github.env.artifactName }}
31+
packageName: ${{ github.env.packageName }}
32+
appNameEnvVar: ${{ github.env.appNameEnvVar }}
33+
publishProfileSecret: ${{ github.env.publishProfileSecret }}
2834
secrets: inherit # Pass repository secrets to the deployment workflow.
2935

3036
deploy-to-production:
3137
needs: deploy-to-test
32-
uses: ./.github/workflows/AHK.GitHub.Monitor-deploy.template.yml
38+
uses: ./.github/workflows/AzureFunctions-deploy.template.yml
3339
with:
34-
artifactName: ${{ github.env.artifactName }}
3540
environmentName: production
41+
artifactName: ${{ github.env.artifactName }}
42+
packageName: ${{ github.env.packageName }}
43+
appNameEnvVar: ${{ github.env.appNameEnvVar }}
44+
publishProfileSecret: ${{ github.env.publishProfileSecret }}
3645
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
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.Api/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.

.github/workflows/Ahk.GitHub.Monitor-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ jobs:
5555
uses: actions/upload-artifact@v4
5656
with:
5757
name: ${{ env.artifactName }}
58-
path: ./output # Put the path to the build artifact files directory here.
58+
path: ./output

.github/workflows/AHK.GitHub.Monitor-deploy.template.yml renamed to .github/workflows/AzureFunctions-deploy.template.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy TEMPLATE AHK.GitHub.Monitor
1+
name: Deploy Functions TEMPLATE
22

33
on:
44
# Allows this workflow to be called from the deployment workflow, but the parameters must be provided.
@@ -12,6 +12,10 @@ on:
1212
description: The name of the environment to deploy to.
1313
required: true
1414
type: string
15+
packageName:
16+
description: The name of the package from the artifact to deploy.
17+
required: true
18+
type: string
1519

1620
jobs:
1721
deploy:
@@ -28,6 +32,6 @@ jobs:
2832
uses: Azure/functions-action@v1
2933
id: fa
3034
with:
31-
app-name: ${{ env.AHK_GitHub_Monitor_App_Name }} # Replace with your app name
32-
publish-profile: ${{ secrets.AHK_GitHub_Monitor_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
33-
package: './buildArtifact/Ahk.GitHub.Monitor'
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)