-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (114 loc) · 4.25 KB
/
DeployEverything.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Deploy Everything
on:
workflow_call:
inputs:
env:
required: true
default: "Test"
type: string
secrets:
AZURE_CREDENTIALS:
required: true
AZURE_STATIC_WEB_APPS_API_TOKEN:
required: true
TERRAFORM_STATE_ACCESS_KEY:
required: true
env:
AZURE_WEBAPP_PACKAGE_PATH: PocketDDD.Server.WebAPI/publish
CONFIGURATION: Release
DOTNET_CORE_VERSION: 8.0.x
WORKING_DIRECTORY: PocketDDD.Server/PocketDDD.Server.WebAPI
jobs:
deploy_terraform:
runs-on: ubuntu-latest
name: Deploy terraform
environment: ${{ inputs.env }}
defaults:
run:
working-directory: ./terraform
steps:
- uses: actions/checkout@v4
- name: Log in with Azure
uses: azure/login@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
- name: Setup terraform
uses: hashicorp/setup-terraform@v3
- run: |
terraform init -backend-config="key=${{ inputs.env }}.terraform.tfstate"
terraform apply -auto-approve --var-file ../tfvars/${{ inputs.env }}.tfvars
env:
ARM_ACCESS_KEY: ${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
build_api_server:
runs-on: ubuntu-latest
name: Build API Server
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Restore
run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
- name: Build
run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test "${{ env.WORKING_DIRECTORY }}" --no-build
- name: Publish
run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v4
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy_api_server:
name: Deploy API Server
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
needs: [deploy_terraform, build_api_server]
steps:
- name: Log in with Azure
uses: azure/login@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: pocketddd-${{ inputs.env }}-api-server-web-app
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
build_and_deploy_blazor_client:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
name: Build and Deploy Blazor Client
needs: deploy_terraform
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Log in with Azure
uses: azure/login@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
- run: |
cp PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot/appsettings.${{ inputs.env }}.json PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot/appsettings.Production.json
- run: |
apiToken=$(az staticwebapp secrets list --name pocketddd-${{ inputs.env }}-blazorclient --query "properties.apiKey" -o tsv)
echo "WEB_APP_API_TOKEN=$apiToken" >> "$GITHUB_ENV"
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ env.WEB_APP_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/PocketDDD.BlazorClient/PocketDDD.BlazorClient" # App source code path
api_location: "" # Api source code path - optional
output_location: "wwwroot" # Built app content directory - optional
###### End of Repository/Build Configurations ######