dotnet-podcasts/.github/workflows/podcast-hub-pr.yml

72 lines
2.5 KiB
YAML
Raw Normal View History

2022-12-01 00:18:21 +08:00
name: Podcast Hub CICD - Staging
2022-12-01 00:07:38 +08:00
on:
pull_request:
branches: [ main ]
paths:
- 'src/Services/ListenTogether/**'
- 'deploy/Services/hub.bicep'
2022-12-01 00:44:40 +08:00
- '.github/workflows/podcast-hub-pr.yml'
2022-12-01 00:07:38 +08:00
workflow_dispatch:
jobs:
build:
2022-12-01 00:39:10 +08:00
if: ${{ github.event_name == 'pull_request'}}
2022-12-01 00:07:38 +08:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
2022-12-01 07:05:06 +08:00
dotnet-version: '7.0.x'
2022-12-01 00:07:38 +08:00
include-prerelease: true
- name: Build
run: dotnet build --configuration Release src/Services/ListenTogether/ListenTogether.Hub
- name: Publish
run: dotnet publish --configuration Release src/Services/ListenTogether/ListenTogether.Hub --output hub
- uses: actions/upload-artifact@master
with:
name: drop
path: hub
deploy:
needs: build
environment:
2022-12-01 00:39:10 +08:00
name: staging
2022-12-01 00:07:38 +08:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: Bicep template
uses: azure/powershell@v1
with:
azPSVersion: '3.1.0'
inlineScript: |
az extension add --name containerapp
2022-12-01 04:08:21 +08:00
$STORAGEKEY=$(az storage account keys list -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n ${{secrets.STORAGE_NAME}} --query [0].value -o tsv)
2022-12-01 06:29:34 +08:00
$PODCAST_API_URL ="https://"+$(az containerapp show -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n ${{ secrets.API_RESOURCE_NAME }} -o tsv --query properties.configuration.ingress.fqdn)+"/"
2022-12-01 04:08:21 +08:00
az deployment group create -n ghactionlistentogether${{ github.sha }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --template-file deploy/Services/hub.bicep --parameters webAppName=${{secrets.HUB_WEBAPP_NAME}} servicePlanName=${{secrets.SERVICE_PLAN_NAME}} podcastApiUrl=$PODCAST_API_URL storageAccountKey=$STORAGEKEY storageAccountName=${{secrets.STORAGE_NAME}} administratorLogin=${{secrets.PODCASTDB_USER_LOGIN}} administratorLoginPassword=${{secrets.PODCASTDB_USER_PASSWORD}} serverName=${{secrets.PODCASTDB_SERVER_NAME}}
2022-12-01 00:07:38 +08:00
- uses: actions/download-artifact@master
with:
name: drop
path: hub
- name: Azure WebApp
uses: Azure/webapps-deploy@v2
with:
2022-12-01 00:27:05 +08:00
app-name: ${{ secrets.HUB_WEBAPP_NAME }}
2022-12-01 00:07:38 +08:00
package: hub