-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set up CI/CD (build stage) with SonarCloud
- Loading branch information
1 parent
a8be447
commit 9d7c4eb
Showing
2 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
name: Development CI/CD Workflows | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build and analyze | ||
runs-on: windows-latest | ||
steps: | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: "zulu" # Alternative distribution options are available. | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~\sonar\cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Cache SonarCloud scanner | ||
id: cache-sonar-scanner | ||
uses: actions/cache@v4 | ||
with: | ||
path: .\.sonar\scanner | ||
key: ${{ runner.os }}-sonar-scanner | ||
restore-keys: ${{ runner.os }}-sonar-scanner | ||
|
||
- name: Install SonarCloud scanner | ||
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | ||
shell: powershell | ||
run: | | ||
echo "Begin Installing SonarCloud" | ||
New-Item -Path .\.sonar\scanner -ItemType Directory | ||
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | ||
echo "End Installing SonarCloud" | ||
continue-on-error: false | ||
|
||
- name: Set up .NET Core | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: "8.x" | ||
|
||
- name: Store dependencies | ||
shell: powershell | ||
run: | | ||
echo "Begin Restoring" | ||
dotnet restore src/EventHub.Presentation/EventHub.Presentation.csproj | ||
echo "End Restoring" | ||
continue-on-error: false | ||
|
||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
shell: powershell | ||
run: | | ||
echo "Begin scanning" | ||
.\.sonar\scanner\dotnet-sonarscanner begin /k:"tranvuongduy2003_EventHub" /o:"tranvuongduy2003" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" | ||
echo "Begin Building" | ||
dotnet build src/EventHub.Presentation/EventHub.Presentation.csproj -c Release -o ./build | ||
echo "End Building" | ||
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | ||
echo "End Scanning" | ||
continue-on-error: false | ||
|
||
- name: Publish | ||
shell: powershell | ||
run: | | ||
echo "Begin Publishing" | ||
dotnet publish src/EventHub.Presentation/EventHub.Presentation.csproj -c Release -o ./publish | ||
echo "End Publishing" | ||
continue-on-error: false | ||
|
||
- name: Upload artifact for deployment job | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: .net-app | ||
path: ./publish | ||
|
||
# deploy: | ||
# runs-on: windows-latest | ||
# needs: build | ||
# environment: | ||
# name: "Production" | ||
# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
|
||
# steps: | ||
# - name: Download artifact from build job | ||
# uses: actions/download-artifact@v4 | ||
# with: | ||
# name: .net-app | ||
|
||
# - name: Deploy to Azure Web App | ||
# id: deploy-to-webapp | ||
# uses: azure/webapps-deploy@v3 | ||
# with: | ||
# app-name: "EventHubAPIServer" | ||
# slot-name: "Production" | ||
# package: . | ||
# publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_2E162A0AE3134EF8992B4DD6656A4E66 }} |
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