Update to Steeltoe v4.0-rc1 #23
Workflow file for this run
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
| name: Build and stage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| checks: write | |
| contents: read | |
| pull-requests: write | |
| statuses: write | |
| jobs: | |
| build: | |
| name: Build and publish app | |
| env: | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
| DOTNET_NOLOGO: true | |
| DOTNET_VERSION: '8.0' | |
| ASPNETCORE_ENVIRONMENT: Staging | |
| 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 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: published-app | |
| path: publish | |
| deploy: | |
| name: Deploy | |
| if: ${{ github.secret_source == 'Actions' }} | |
| environment: | |
| name: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || vars.STAGING_SLOT_NAME }} | |
| url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
| env: | |
| SLOT_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || vars.STAGING_SLOT_NAME }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: published-app | |
| - name: Login to Azure | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{ secrets.AZURE_CREDENTIALS }} | |
| - name: If PR, create a new staging slot | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: az webapp deployment slot create --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_WEBAPP_NAME}} --slot ${{ env.SLOT_NAME }} --configuration-source ${{ vars.STAGING_SLOT_NAME }} | |
| - name: Deploy to staging slot | |
| id: deploy-to-webapp | |
| if: ${{ github.secret_source == 'Actions' }} | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: ${{ vars.AZURE_WEBAPP_NAME }} | |
| package: '.' | |
| slot-name: ${{ env.SLOT_NAME }} | |
| - name: If PR, comment with the preview link | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: mshick/add-pr-comment@v2 | |
| with: | |
| message: | | |
| ## Preview link: https://${{ vars.AZURE_WEBAPP_NAME }}-${{ env.SLOT_NAME }}.azurewebsites.net | |
| - Your changes have been deployed to the preview site. The preview site will update as you add more commits to this branch. | |
| - The preview link is shareable, but will be deleted when the pull request is merged or closed. | |
| ### Need to pair with a custom NetCoreToolService address? | |
| A team member can use this az CLI command, replacing <this-PR-number> and <other-pr-number> for valid numbers: | |
| ```bash | |
| az webapp config appsettings set --resource-group steeltoe --name initializr-service --slot pr-<this-PR-number> --settings InitializrService__NetCoreToolService__Uri=https://netcoretoolservice-pr-<other-pr-number>.azurewebsites.net/api | |
| ``` | |
| > *This is an automated message.* | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} |