dotnet-podcasts/.github/workflows/template-web.yml

85 lines
2.7 KiB
YAML
Raw Normal View History

2022-12-05 23:09:27 +08:00
on:
workflow_call:
inputs:
environment:
required: true
type: string
jobs:
build:
environment:
name: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
- name: Install wasm-tools
run: dotnet workload install wasm-tools
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Set backend env variables
uses: azure/powershell@v1
with:
azPSVersion: "latest"
inlineScript: |
az extension add --name containerapp
$apiUrl = "https://$(az containerapp show -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n ${{ secrets.API_RESOURCE_NAME }} -o tsv --query properties.configuration.ingress.fqdn)"
echo "PODCAST_API_URL=$apiUrl" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Set Blazor WASM app settings
uses: microsoft/variable-substitution@v1
with:
files: "src/Web/Client/wwwroot/appsettings.json"
env:
PodcastApi.BaseAddress: ${{ env.PODCAST_API_URL }}
ListenTogetherHub: "https://${{secrets.HUB_WEBAPP_NAME}}.azurewebsites.net/listentogether"
- name: Build
run: dotnet build src/Web/Server --configuration Release
- name: Publish
run: dotnet publish --configuration Release src/Web/Server --output web
- uses: actions/upload-artifact@v3
with:
name: drop
path: web
2022-12-05 23:09:27 +08:00
deploy:
needs: build
2022-12-05 23:09:27 +08:00
environment:
2022-12-05 23:19:43 +08:00
name: ${{ inputs.environment }}
2022-12-05 23:09:27 +08:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
with:
2022-12-05 23:29:57 +08:00
creds: ${{ secrets.AZURE_CREDENTIALS }}
2022-12-05 23:09:27 +08:00
- name: Deploy Bicep template
uses: azure/powershell@v1
with:
azPSVersion: "3.1.0"
inlineScript: |
2022-12-07 05:51:58 +08:00
az deployment group create -n ghaction -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --template-file deploy/Web/web.bicep --parameters webAppName=${{ secrets.WEBAPP_NAME }} servicePlanName=${{ secrets.SERVICE_PLAN_NAME }} servicePlanSku=${{ secrets.SERVICE_PLAN_SKU }} hubWebAppName=${{ secrets.HUB_WEBAPP_NAME }} apiName=${{secrets.API_RESOURCE_NAME}}
2022-12-05 23:09:27 +08:00
- name: Download web artifacts
uses: actions/download-artifact@v3
with:
name: drop
path: web
- name: Azure WebApp
uses: Azure/webapps-deploy@v2
with:
app-name: ${{ secrets.WEBAPP_NAME }}
package: web