Merge pull request #76 from flcdrg/dependabot/nuget/src/Microsoft.Ext… #213
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: Build and Deploy | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
workflow_dispatch: | |
env: | |
AZURE_FUNCTIONAPP_PACKAGE_PATH: "./src/CfsAlerts" | |
DOTNET_VERSION: "8.0.x" | |
jobs: | |
build-bicep: | |
name: Build Bicep | |
runs-on: ubuntu-latest | |
concurrency: | |
group: bicep | |
cancel-in-progress: false | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
- name: "Login via Azure CLI" | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} | |
- name: Test | |
uses: azure/arm-deploy@v2 | |
with: | |
resourceGroupName: ${{ vars.AZURE_RESOURCE_GROUP }} | |
template: ./bicep/main.bicep | |
parameters: "mastadonToken=${{ secrets.MASTODONSETTINGS_TOKEN }}" | |
failOnStdErr: false | |
additionalArguments: --what-if | |
- name: Archive Bicep | |
if: success() && github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bicep | |
path: "./bicep" | |
include-hidden-files: true | |
build-dotnet: | |
name: Build .NET | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: "Build" | |
shell: bash | |
run: | | |
dotnet build --configuration Release --output ./output | |
ls -al ./output | |
working-directory: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} | |
- name: "Archive Project" | |
if: success() && github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: function-app | |
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output | |
include-hidden-files: true | |
deploy: | |
name: Deploy | |
needs: | |
- build-bicep | |
- build-dotnet | |
runs-on: ubuntu-latest | |
environment: dev | |
concurrency: | |
group: deploy | |
cancel-in-progress: false | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: "Download Artifact" | |
uses: actions/download-artifact@v4 | |
with: | |
name: bicep | |
path: "./bicep" | |
- name: "Login via Azure CLI" | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} | |
- name: deploy | |
uses: azure/arm-deploy@v2 | |
id: deploy | |
with: | |
resourceGroupName: ${{ vars.AZURE_RESOURCE_GROUP }} | |
template: ./bicep/main.bicep | |
parameters: "mastadonToken=${{ secrets.MASTODONSETTINGS_TOKEN }}" | |
failOnStdErr: false | |
- name: "Download Artifact" | |
uses: actions/download-artifact@v4 | |
with: | |
name: function-app | |
path: "./function-app" | |
- name: "Run Azure Functions Action" | |
uses: Azure/functions-action@v1 | |
id: fa | |
with: | |
app-name: ${{ steps.deploy.outputs.functionAppName }} | |
package: "./function-app" | |
- name: Application Insights Annotate | |
uses: ChristopheLav/appinsights-annotate@v2.0.2 | |
with: | |
app-id: ${{ secrets.APPINSIGHTS_APP_ID }} | |
name: ${{ github.event.head_commit.message || github.sha }} | |
treat-error-as-warning: true | |
- name: "Start Orchestration" | |
shell: bash | |
continue-on-error: true | |
run: | | |
# Get function key | |
KEY=$(az functionapp function keys list --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ steps.deploy.outputs.functionAppName }} --function-name StartOrchestration --query "default" -o tsv) | |
URL=$(az functionapp function show --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ steps.deploy.outputs.functionAppName }} --function-name StartOrchestration --query "invokeUrlTemplate" -o tsv) | |
# Call function https://func-cfsalerts-prod-australiasoutheast.azurewebsites.net/api/StartOrchestration?code=tyPZ23gIY37ICFejcbd-2OwQV39GhLbDs2o4N8LVXgXdAzFu12YEMA== | |
echo "$URL?code=$KEY" | |
curl -X GET $URL?code=$KEY |