03-Deployment-Function #5
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: 03-Deployment-Function | |
on: | |
push: | |
paths: | |
- 'src/github-process-function/**' | |
workflow_dispatch: | |
env: | |
CONFIGURATION: 'release' | |
AZ_RG_NAME: 'rg-ghdashboard' | |
AZ_FUNC_NAME: 'func-ghdashboard' | |
CSPROJ: 'src/github-dashboard.function/github-dashboard.function.csproj' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET Core SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore ${{ env.CSPROJ }} | |
- name: Build | |
run: dotnet build ${{ env.CSPROJ }} --configuration ${{ env.CONFIGURATION }} --no-restore | |
- name: Publish | |
run: dotnet publish --configuration ${{ env.CONFIGURATION }} --output MyPublishFunction ${{ env.CSPROJ }} | |
- name: Upload dotnet publish results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dotnet-publish | |
path: MyPublishFunction | |
- name: Upload SQL scripts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sql-publish | |
path: 'src/sqlscripts/*.sql' | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: dotnet-publish | |
path: my-app-artifact | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sql-publish | |
path: my-sql-artifact | |
- name: Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZ_CREDENTIALS }} | |
- name: 'Run Azure Functions action' | |
uses: Azure/functions-action@v1 | |
with: | |
app-name: ${{ env.AZ_FUNC_NAME }} | |
package: my-app-artifact | |
- name: Set Function Settings | |
uses: Azure/appservice-settings@v1 | |
with: | |
app-name: ${{ env.AZ_FUNC_NAME }} | |
app-settings-json: | | |
[ | |
{ | |
"name": "MyDbContext", | |
"value": "${{ env.AZ_SQL_CONNECTION_STRING }}", | |
"slotSetting": false | |
} | |
] | |
- name: Restart function | |
run: az functionapp restart --name ${{ env.AZ_FUNC_NAME }} --resource-group ${{ env.AZ_RG_NAME }} | |
- name: Run SQL Scripts | |
uses: azure/[email protected] | |
with: | |
connection-string: ${{ secrets.AZ_SQL_CONNECTION_STRING }} | |
path: 'my-sql-artifact/CreateTables.sql' |