generated from SSWConsulting/SSW.GitHub.Template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3924b1
commit 51a9699
Showing
2 changed files
with
130 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
# More GitHub Actions for Azure: https://github.com/Azure/actions | ||
|
||
name: Reusable Build and Deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
# The environment to deploy to (Staging or Production) | ||
EnvironmentName: | ||
required: true | ||
type: string | ||
# The name of the resource in Azure | ||
AzureWebAppName: | ||
required: true | ||
type: string | ||
# The URL for the relevant API | ||
ApiBaseUrl: | ||
required: true | ||
type: string | ||
|
||
secrets: | ||
AzureWebAppSecret: | ||
required: true | ||
AzureStaticWebAppsApiToken: | ||
required: true | ||
GithubRepoToken: | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3.3.0 | ||
|
||
- name: Set up .NET Core | ||
uses: actions/setup-dotnet@v3.0.3 | ||
with: | ||
dotnet-version: '7.x' | ||
|
||
# https://stackoverflow.com/questions/60521929/change-variables-in-appsettings-when-deploying-with-github-actions | ||
# This will fail if done before the build step | ||
- name: App Settings Variable Substitution | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: './src/WebUI/wwwroot/appsettings.json' | ||
env: | ||
ApiBaseUrl: ${{ github.event.inputs['ApiBaseUrl'] }} | ||
|
||
- name: Build with dotnet | ||
run: dotnet build --configuration Release | ||
|
||
- name: dotnet publish WebAPI | ||
run: dotnet publish ./src/WebAPI -c Release -o ./publish/api | ||
|
||
- name: dotnet publish WebUI | ||
run: dotnet publish ./src/WebUI -c Release -o ./publish/ui | ||
|
||
- name: Upload API artifact for deployment job | ||
uses: actions/upload-artifact@v3.1.2 | ||
with: | ||
name: .net-app-api | ||
path: ./publish/api | ||
|
||
- name: Upload WebUI artifact for deployment job | ||
uses: actions/upload-artifact@v3.1.2 | ||
with: | ||
name: .net-app-webui | ||
path: ./publish/ui | ||
|
||
deploy-api: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: | ||
name: ${{ github.event.inputs['EnvironmentName'] }} | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
|
||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3.0.2 | ||
with: | ||
name: .net-app-api | ||
|
||
- name: Deploy to Azure Web App | ||
id: deploy-to-webapp | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: "${{ github.event.inputs['AzureWebAppName'] }}" | ||
slot-name: 'Production' # The environment in Azure, Production is just the name of the slot | ||
publish-profile: ${{ secrets.AzureWebAppSecret }} | ||
package: . | ||
|
||
deploy-webui: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: | ||
name: ${{ github.event.inputs['EnvironmentName'] }} | ||
url: ${{ steps.deploy-to-staticwebapp.outputs.static_web_app_url }} | ||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3.0.2 | ||
with: | ||
name: .net-app-webui | ||
|
||
- name: Deploy Static Web App | ||
id: deploy-to-staticwebapp | ||
uses: Azure/static-web-apps-deploy@v1 | ||
with: | ||
azure_static_web_apps_api_token: ${{ secrets.AzureStaticWebAppsApiToken }} | ||
repo_token: ${{ secrets.GithubRepoToken }} # Used for Github integrations (i.e. PR comments) | ||
skip_app_build: true | ||
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: "./wwwroot" # App source code path | ||
config_file_location: "./" | ||
api_location: '' # Api source code path - optional | ||
output_location: '' # 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