Merge pull request #661 from cultpodcasts/bugfix/delete-bluesky-post #126
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Provision and Deploy | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
DEPLOYMENT_RESOURCEGROUP_NAME: AutomatedInfra | |
MANAGEMENT_RESOURCEGROUP_NAME: ${{ secrets.MANAGEMENT_RESOURCEGROUP_NAME }} | |
AZURE_KEYVAULT_NAME: ${{ secrets.AZURE_KEYVAULT_NAME }} | |
storageName: cultpodcastsstg | |
suffix: infra | |
location: uksouth | |
functionState: start | |
API_PACKAGE_PATH: './Cloud/Api' | |
DISCOVER_PACKAGE_PATH: './Cloud/Discovery' | |
INDEXER_PACKAGE_PATH: './Cloud/Indexer' | |
DOTNET_VERSION: '9.0.x' | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 9.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
provision: | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
continue-on-error: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Azure Login | |
uses: Azure/login@v2.2.0 | |
with: | |
client-id: ${{ secrets.DEPLOYMENT_Client_ID }} | |
tenant-id: ${{ secrets.AZURE_Tenant_ID }} | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
- name: Storage (Deploy Bicep) | |
id: bicepstoragedeploy | |
uses: azure/bicep-deploy@v1 | |
with: | |
type: deployment | |
operation: create | |
name: bicep-storage-${{ github.run_number }} | |
scope: resourceGroup | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
resource-group-name: ${{ env.DEPLOYMENT_RESOURCEGROUP_NAME }} | |
template-file: ./Infrastructure/function-storage.bicep | |
parameters: '{"location":"${{ env.location }}", "storageName":"${{ env.storageName }}"}' | |
- name: Application-Insights (Deploy Bicep) | |
id: bicepappinsightsdeploy | |
uses: azure/bicep-deploy@v1 | |
with: | |
type: deployment | |
operation: create | |
name: bicep-appinsights-${{ github.run_number }} | |
scope: resourceGroup | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
resource-group-name: ${{ env.DEPLOYMENT_RESOURCEGROUP_NAME }} | |
template-file: ./Infrastructure/function-application-insights.bicep | |
parameters: '{"location":"${{ env.location }}", "suffix":"${{ env.suffix }}"}' | |
- name: Functions (Deploy Bicep) | |
id: bicepfunctionsdeploy | |
uses: azure/bicep-deploy@v1 | |
with: | |
type: deployment | |
operation: create | |
name: bicep-functions-${{ github.run_number }} | |
scope: resourceGroup | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
resource-group-name: ${{ env.DEPLOYMENT_RESOURCEGROUP_NAME }} | |
template-file: ./Infrastructure/functions.bicep | |
parameters-file: ./Infrastructure/functions.bicepparam | |
parameters: '{"location":"${{ env.location }}", "suffix":"${{ env.suffix }}", "storageName":"${{ env.storageName }}"}' | |
- name: Set Function State | |
if: ${{ (env.functionState == 'start') || (env.functionState == 'stop') }} | |
uses: Azure/cli@v2.1.0 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
az functionapp ${{ env.functionState }} --name api-infra --resource-group ${{ env.DEPLOYMENT_RESOURCEGROUP_NAME }} | |
az functionapp ${{ env.functionState }} --name indexer-infra --resource-group ${{ env.DEPLOYMENT_RESOURCEGROUP_NAME }} | |
az functionapp ${{ env.functionState }} --name discover-infra --resource-group ${{ env.DEPLOYMENT_RESOURCEGROUP_NAME }} | |
api-build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: provision | |
permissions: | |
id-token: write #This is required for requesting the JWT | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: 'Resolve Project Dependencies Using Dotnet' | |
shell: bash | |
run: | | |
pushd './${{ env.API_PACKAGE_PATH }}' | |
dotnet build --configuration Release --output ./output | |
popd | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.DEPLOYMENT_Client_ID }} | |
tenant-id: ${{ secrets.AZURE_Tenant_ID }} | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
- name: 'Run Azure Functions Action' | |
uses: Azure/functions-action@v1 | |
id: fa | |
with: | |
app-name: 'api-infra' | |
slot-name: 'Production' | |
package: '${{ env.API_PACKAGE_PATH }}/output' | |
discover-build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: provision | |
permissions: | |
id-token: write #This is required for requesting the JWT | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: 'Resolve Project Dependencies Using Dotnet' | |
shell: bash | |
run: | | |
pushd './${{ env.DISCOVER_PACKAGE_PATH }}' | |
dotnet build --configuration Release --output ./output | |
popd | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.DEPLOYMENT_Client_ID }} | |
tenant-id: ${{ secrets.AZURE_Tenant_ID }} | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
- name: 'Run Azure Functions Action' | |
uses: Azure/functions-action@v1 | |
id: fa | |
with: | |
app-name: 'discover-infra' | |
slot-name: 'Production' | |
package: '${{ env.DISCOVER_PACKAGE_PATH }}/output' | |
indexer-build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: provision | |
permissions: | |
id-token: write #This is required for requesting the JWT | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: 'Resolve Project Dependencies Using Dotnet' | |
shell: bash | |
run: | | |
pushd './${{ env.INDEXER_PACKAGE_PATH }}' | |
dotnet build --configuration Release --output ./output | |
popd | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.DEPLOYMENT_Client_ID }} | |
tenant-id: ${{ secrets.AZURE_Tenant_ID }} | |
subscription-id: ${{ secrets.AZURE_Subscription_ID }} | |
- name: 'Run Azure Functions Action' | |
uses: Azure/functions-action@v1 | |
id: fa | |
with: | |
app-name: 'indexer-infra' | |
slot-name: 'Production' | |
package: '${{ env.INDEXER_PACKAGE_PATH }}/output' |