-
Notifications
You must be signed in to change notification settings - Fork 0
Add CI workflow that tests then deploys to Azure App Service #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Build, test and deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| # The App Service resource name. Azure appends a unique suffix to the public | ||
| # hostname (boggle-fxe8hwa0duhvc8hc.centralus-01.azurewebsites.net), but the | ||
| # resource name itself is just this. | ||
| AZURE_WEBAPP_NAME: boggle | ||
| DOTNET_VERSION: '8.0.x' | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: actions/setup-dotnet@v6 | ||
| with: | ||
| dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
|
||
| - name: Restore | ||
| run: dotnet restore Boggle.sln | ||
|
|
||
| - name: Build | ||
| run: dotnet build Boggle.sln --configuration Release --no-restore | ||
|
|
||
| - name: Test | ||
| run: dotnet test UnitTests/UnitTests.csproj --configuration Release --no-build --verbosity normal | ||
|
|
||
| # Publish only the web project. The solution also contains UnitTests, | ||
| # and publishing at solution level would try to package that too. | ||
| - name: Publish | ||
| if: github.event_name != 'pull_request' | ||
| run: dotnet publish Boggle/Boggle.csproj --configuration Release --output ./publish | ||
|
|
||
| - name: Upload artifact | ||
| if: github.event_name != 'pull_request' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: webapp | ||
| path: ./publish | ||
|
|
||
| deploy: | ||
| # Pull requests are built and tested, but never deployed. | ||
| if: github.event_name != 'pull_request' | ||
| needs: build-and-test | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: production | ||
| url: ${{ steps.deploy.outputs.webapp-url }} | ||
| steps: | ||
| - name: Download artifact | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: webapp | ||
| path: ./publish | ||
|
|
||
| - name: Deploy to Azure Web App | ||
| id: deploy | ||
| uses: azure/webapps-deploy@v3 | ||
| with: | ||
| app-name: ${{ env.AZURE_WEBAPP_NAME }} | ||
| publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | ||
| package: ./publish | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When two commits are pushed to
mainclose together, this workflow allows both build-and-deploy runs to proceed concurrently; if the earlier run reaches Azure last because its build or upload is slower, it overwrites the newer production deployment with stale code. Add a deployment concurrency group, preferably with cancellation of superseded runs, so production ends on the latest commit.Useful? React with 👍 / 👎.