2021-11-30 03:54:48 +08:00
|
|
|
name: Podcast Web CICD
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [main]
|
|
|
|
paths:
|
|
|
|
- "src/Web/**"
|
|
|
|
- ".github/workflows/podcast-web.yml"
|
2022-09-18 01:39:52 +08:00
|
|
|
- "deploy/Web/web.bicep"
|
2021-11-30 03:54:48 +08:00
|
|
|
pull_request:
|
|
|
|
branches: [main]
|
|
|
|
paths:
|
|
|
|
- "src/Web/**"
|
|
|
|
- ".github/workflows/podcast-web.yml"
|
2022-09-18 01:39:52 +08:00
|
|
|
- "deploy/Web/web.bicep"
|
2021-11-30 03:54:48 +08:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2022-12-05 02:30:26 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-11-30 03:54:48 +08:00
|
|
|
|
|
|
|
- name: Set up .NET Core
|
2022-11-03 04:25:36 +08:00
|
|
|
uses: actions/setup-dotnet@v3
|
2021-11-30 03:54:48 +08:00
|
|
|
with:
|
2022-10-19 08:06:13 +08:00
|
|
|
dotnet-version: "7.0.x"
|
2021-11-30 03:54:48 +08:00
|
|
|
|
|
|
|
- name: Install wasm-tools
|
|
|
|
run: dotnet workload install wasm-tools
|
|
|
|
|
|
|
|
- uses: azure/login@v1
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
2022-12-05 02:03:32 +08:00
|
|
|
deployStaging:
|
|
|
|
name: 'Deploy PR to Staging environment'
|
2021-11-30 03:54:48 +08:00
|
|
|
needs: build
|
2022-09-17 00:18:25 +08:00
|
|
|
environment:
|
2022-12-05 02:03:32 +08:00
|
|
|
name: staging
|
2022-12-05 04:22:23 +08:00
|
|
|
if: "!startsWith(github.ref, 'refs/heads/main')"
|
2021-11-30 03:54:48 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-12-05 02:30:26 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-11-30 03:54:48 +08:00
|
|
|
|
|
|
|
- uses: azure/login@v1
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
|
|
|
2022-12-05 02:03:32 +08:00
|
|
|
- name: Deploy Bicep template
|
2022-12-01 06:19:22 +08:00
|
|
|
uses: azure/powershell@v1
|
|
|
|
with:
|
2022-12-05 02:03:32 +08:00
|
|
|
azPSVersion: "3.1.0"
|
2022-12-01 06:19:22 +08:00
|
|
|
inlineScript: |
|
2022-12-05 02:03:32 +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}} apiContainerAppName=${{ secrets.API_RESOURCE_NAME }} hubWebAppName=${{secrets.HUB_WEBAPP_NAME}}
|
|
|
|
|
|
|
|
- name: Download web artifacts
|
|
|
|
uses: actions/download-artifact@master
|
|
|
|
with:
|
|
|
|
name: drop
|
|
|
|
path: web
|
|
|
|
|
|
|
|
- name: Azure WebApp
|
|
|
|
uses: Azure/webapps-deploy@v2
|
|
|
|
with:
|
|
|
|
app-name: ${{ secrets.WEBAPP_NAME }}
|
|
|
|
package: web
|
|
|
|
|
|
|
|
deployProd:
|
|
|
|
name: 'Deploy main branch commit to Production environment'
|
|
|
|
needs: build
|
|
|
|
environment:
|
|
|
|
name: prod
|
2022-12-05 04:22:23 +08:00
|
|
|
if: startsWith(github.ref, 'refs/heads/main')
|
2022-12-05 02:03:32 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-12-05 02:30:26 +08:00
|
|
|
- uses: actions/checkout@v3
|
2022-12-05 02:03:32 +08:00
|
|
|
|
|
|
|
- uses: azure/login@v1
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
2022-12-01 06:19:22 +08:00
|
|
|
|
2022-09-18 01:39:52 +08:00
|
|
|
- name: Deploy Bicep template
|
2021-11-30 03:54:48 +08:00
|
|
|
uses: azure/powershell@v1
|
|
|
|
with:
|
|
|
|
azPSVersion: "3.1.0"
|
|
|
|
inlineScript: |
|
2022-12-05 02:03:32 +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}} apiContainerAppName=${{ secrets.API_RESOURCE_NAME }} hubWebAppName=${{secrets.HUB_WEBAPP_NAME}}
|
2021-11-30 03:54:48 +08:00
|
|
|
|
|
|
|
- name: Download web artifacts
|
|
|
|
uses: actions/download-artifact@master
|
|
|
|
with:
|
|
|
|
name: drop
|
|
|
|
path: web
|
2022-09-17 00:18:25 +08:00
|
|
|
|
2021-11-30 03:54:48 +08:00
|
|
|
- name: Azure WebApp
|
|
|
|
uses: Azure/webapps-deploy@v2
|
|
|
|
with:
|
|
|
|
app-name: ${{ secrets.WEBAPP_NAME }}
|
2021-12-09 01:03:48 +08:00
|
|
|
package: web
|
2022-09-16 23:02:00 +08:00
|
|
|
|
|
|
|
test:
|
2022-12-05 02:17:12 +08:00
|
|
|
needs: [deployStaging, deployProd]
|
2022-12-05 02:35:50 +08:00
|
|
|
if: ${{ always() }}
|
2022-09-16 23:02:00 +08:00
|
|
|
timeout-minutes: 60
|
|
|
|
runs-on: ubuntu-latest
|
2022-12-05 02:03:32 +08:00
|
|
|
container: mcr.microsoft.com/playwright:v1.27.1-focal
|
2022-09-16 23:02:00 +08:00
|
|
|
env:
|
2022-09-16 23:17:53 +08:00
|
|
|
BASEURL: https://${{secrets.WEBAPP_NAME}}.azurewebsites.net # sets value for URL to test
|
2022-09-16 23:02:00 +08:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: src/Web/E2E
|
|
|
|
steps:
|
2022-12-05 02:30:26 +08:00
|
|
|
- uses: actions/checkout@v3
|
2022-09-16 23:14:55 +08:00
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: "14.x"
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
- name: Run Playwright tests
|
|
|
|
run: |
|
|
|
|
HOME=/root npx playwright test
|
|
|
|
|
|
|
|
- name: Create test summary
|
|
|
|
uses: test-summary/action@dist
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
paths: src/Web/E2E/test-results/junit.xml
|
|
|
|
|
|
|
|
- name: Upload HTML report
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
name: playwright-report
|
|
|
|
path: src/Web/E2E/playwright-report/
|
|
|
|
retention-days: 30
|