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

122 lines
3.8 KiB
YAML
Raw Normal View History

2021-11-30 03:54:48 +08:00
name: Podcast Web CICD
on:
push:
branches: [main]
paths:
- "src/Web/**"
- ".github/workflows/podcast-web.yml"
- "deploy/Web/web.deployment.json"
pull_request:
branches: [main]
paths:
- "src/Web/**"
- ".github/workflows/podcast-web.yml"
- "deploy/Web/web.deployment.json"
workflow_dispatch:
env:
API_RESOURCE_NAME: podcastapica
jobs:
build:
environment:
name: prod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.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: |
2022-04-22 03:36:19 +08:00
az extension add --name containerapp
2022-04-22 03:50:14 +08:00
$apiUrl = "https://$(az containerapp show -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n ${{ env.API_RESOURCE_NAME }} -o tsv --query properties.configuration.ingress.fqdn)"
2021-11-30 03:54:48 +08:00
$listenTogetherHubUrl = "https://${{ secrets.HUB_WEBAPP_NAME }}.azurewebsites.net/listentogether"
echo "PODCAST_API_URL=$apiUrl" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "LISTEN_TOGETHER_HUB_URL=$listenTogetherHubUrl" | 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: ${{ env.LISTEN_TOGETHER_HUB_URL }}
- 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@master
with:
name: drop
path: web
outputs:
PodcastApiUrl: ${{ env.PODCAST_API_URL }}
ListenTogetherHubUrl: ${{ env.LISTEN_TOGETHER_HUB_URL }}
deploy:
needs: build
environment:
name: prod
2021-12-09 01:03:48 +08:00
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch') }}
2021-11-30 03:54:48 +08:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy ARM
uses: azure/powershell@v1
with:
azPSVersion: "3.1.0"
inlineScript: |
az deployment group create -n ghaction -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --template-file deploy/Web/web.deployment.json --parameters webAppName=${{secrets.WEBAPP_NAME}} servicePlanName=${{secrets.SERVICE_PLAN_NAME}} servicePlanSku=${{secrets.SERVICE_PLAN_SKU}}
- name: Download web artifacts
uses: actions/download-artifact@master
with:
name: drop
path: web
- name: Update App Service app settings variables
uses: Azure/appservice-settings@v1
with:
app-name: ${{ secrets.WEBAPP_NAME }}
app-settings-json: |
[
{
"name": "PodcastApi__BaseAddress",
"value": "${{ needs.build.outputs.PodcastApiUrl }}"
},
{
"name": "ListenTogetherHub",
"value": "${{ needs.build.outputs.ListenTogetherHubUrl }}"
}
]
- name: Azure WebApp
uses: Azure/webapps-deploy@v2
with:
app-name: ${{ secrets.WEBAPP_NAME }}
2022-09-16 22:50:05 +08:00
package: web