-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate deployment of terraform and apps
- Loading branch information
Showing
21 changed files
with
268 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Deploy Branch Push | ||
on: | ||
push: | ||
branches-ignore: | ||
- 'main' | ||
|
||
|
||
jobs: | ||
deploy_to_test: | ||
uses: ./.github/workflows/DeployEverything.yml | ||
with: | ||
env: "Test2" | ||
secrets: | ||
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} | ||
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
TERRAFORM_STATE_ACCESS_KEY: ${{ secrets.TERRAFORM_STATE_ACCESS_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 ###### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot/appsettings.Production.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"apiUrl": "https://dddsw2023pocketdddserverwebapi.azurewebsites.net/api/", | ||
"apiUrl": "https://pocketddd-production-api-server-web-app.azurewebsites.net/api/", | ||
"fakeBackend": false | ||
} |
4 changes: 0 additions & 4 deletions
4
PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot/appsettings.Test.json
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot/appsettings.Test2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"apiUrl": "https://pocketddd-test2-api-server-web-app.azurewebsites.net/api/", | ||
"fakeBackend": false | ||
} |
4 changes: 4 additions & 0 deletions
4
PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot/appsettings.test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"apiUrl": "https://pocketddd-test-api-server-web-app.azurewebsites.net/api/", | ||
"fakeBackend": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.