Move to GitHub Actions and Azure App Service.net + .NET and dependency updates #3
Workflow file for this run
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 stage | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_VERSION: '8.0' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
checks: write | |
contents: read | |
statuses: write | |
jobs: | |
build: | |
name: Build and publish app | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Set up dependency caching for faster builds | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: dotnet restore | |
run: dotnet restore | |
- name: dotnet build | |
run: dotnet build --no-restore /p:TreatWarningsAsErrors=True | |
- name: dotnet test | |
run: dotnet test --logger trx --results-directory "${{ runner.temp }}" --no-build | |
- name: dotnet test | |
uses: NasAmin/[email protected] | |
with: | |
TRX_PATH: "${{ runner.temp }}" | |
REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: dotnet publish | |
run: dotnet publish src/InitializrService/Steeltoe.InitializrService.csproj -o publish | |
- name: Upload artifact for deployment job | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: published-app | |
path: publish | |
deploy: | |
name: Deploy | |
environment: production | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'pull_request' }} | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: published-app | |
- name: Log into Azure CLI with service principal | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: ${{ vars.AZURE_WEBAPP_NAME }} | |
package: '.' | |
slot-name: 'production' |