107 lines
3.4 KiB
YAML
107 lines
3.4 KiB
YAML
name: Podcast Hub CICD
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'src/Services/ListenTogether/**'
|
|
- 'deploy/Services/hub.bicep'
|
|
- '.github/workflows/podcast-hub.yml'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'src/Services/ListenTogether/**'
|
|
- '.github/workflows/podcast-hub.yml'
|
|
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
|
|
build:
|
|
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'
|
|
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
|
|
|
|
deployStaging:
|
|
name: 'Deploy PR to Staging environment'
|
|
needs: build
|
|
environment:
|
|
name: staging
|
|
if: "!contains(github.ref, 'refs/heads/main')"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- 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 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}} storageAccountName=${{secrets.STORAGE_NAME}} administratorLogin=${{secrets.PODCASTDB_USER_LOGIN}} administratorLoginPassword=${{secrets.PODCASTDB_USER_PASSWORD}} serverName=${{secrets.PODCASTDB_SERVER_NAME}}
|
|
|
|
- uses: actions/download-artifact@master
|
|
with:
|
|
name: drop
|
|
path: hub
|
|
|
|
- name: Azure WebApp
|
|
uses: Azure/webapps-deploy@v2
|
|
with:
|
|
app-name: ${{ secrets.HUB_WEBAPP_NAME }}
|
|
package: hub
|
|
|
|
deployProd:
|
|
name: 'Deploy main branch commit to Production environment'
|
|
needs: build
|
|
environment:
|
|
name: prod
|
|
if: contains(github.ref, 'refs/heads/main')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- 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 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}} storageAccountName=${{secrets.STORAGE_NAME}} administratorLogin=${{secrets.PODCASTDB_USER_LOGIN}} administratorLoginPassword=${{secrets.PODCASTDB_USER_PASSWORD}} serverName=${{secrets.PODCASTDB_SERVER_NAME}}
|
|
|
|
- uses: actions/download-artifact@master
|
|
with:
|
|
name: drop
|
|
path: hub
|
|
|
|
- name: Azure WebApp
|
|
uses: Azure/webapps-deploy@v2
|
|
with:
|
|
app-name: ${{ secrets.HUB_WEBAPP_NAME }}
|
|
package: hub
|