fixed branches on trigger events for workflows #15
This file contains hidden or 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
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | |
# More GitHub Actions for Azure: https://github.com/Azure/actions | |
name: Build, test and deploy | |
on: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
env: | |
AZURE_WEBAPP_NAME: 'AutoHubApp' # set this to your application's name | |
AZURE_WEBAPP_PACKAGE_PATH: './publish' # set this to the path to your web app project, defaults to the repository root | |
DOTNET_VERSION: '8.x' # set this to the dot net version to use | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up .NET Core SDK ${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Restore packages | |
run: dotnet restore | |
- name: Build application | |
run: dotnet build --configuration Release | |
- name: Publish artifact | |
run: dotnet publish -c Release -o ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.AZURE_WEBAPP_NAME }} | |
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Build with dotnet | |
run: dotnet build --configuration Release | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Run tests with dotnet | |
run: dotnet test --no-build --no-restore --configuration Release | |
deploy: | |
name: Deploy to Azure | |
runs-on: ubuntu-latest | |
needs: test | |
environment: | |
name: 'Production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.AZURE_WEBAPP_NAME }} | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZUREAPP_CLIENTID }} | |
tenant-id: ${{ secrets.AZUREAPP_TENANTID }} | |
subscription-id: ${{ secrets.AZUREAPP_SUBSCRIPTIONID }} | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
slot-name: 'Production' | |
package: . | |