Skip to content

Commit

Permalink
Update CI_CD.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mu88 authored Dec 18, 2024
1 parent 0d4039d commit 4bd2ca0
Showing 1 changed file with 18 additions and 52 deletions.
70 changes: 18 additions & 52 deletions .github/workflows/CI_CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,45 @@ on:
- '*'
branches:
- '**'

env:
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}

jobs:
ci_cd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Set up JDK
uses: actions/setup-java@v4
- name: CI/CD
id: mu88-ci-cd
uses: mu88/github-actions/ci-cd@0.1
with:
java-version: 17
distribution: 'zulu'
- name: Restore dependencies
run: dotnet restore ThisIsYourLife.sln
- name: Begin Sonar scan
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:mu88_Project28 /o:mu88 /d:sonar.token=${{ secrets.SONAR_TOKEN }} /d:sonar.host.url=https://sonarcloud.io /d:sonar.cs.opencover.reportsPaths=src/Tests/coverage.opencover.xml /s:$GITHUB_WORKSPACE/SonarQube.Analysis.xml
- name: Build
run: dotnet build --no-restore ThisIsYourLife.sln
- name: Test and collect coverage
run: dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --filter "TestCategory=Unit|TestCategory=Integration"
- name: End Sonar scan
run: dotnet sonarscanner end /d:sonar.token=${{ secrets.SONAR_TOKEN }}
- name: Run system tests
run: dotnet test --no-build --filter "TestCategory=System"
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: registry.hub.docker.com
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Write release version
if: ${{ env.IS_RELEASE == 'true' }}
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build and push Docker non-release
if: ${{ env.IS_RELEASE != 'true' }}
run: |
dotnet publish src/WebApp/WebApp.csproj /t:MultiArchPublish '-p:ContainerImageTags="dev"' -p:ContainerRegistry=registry.hub.docker.com
dotnet publish src/WebApp/WebApp.csproj /t:MultiArchPublish '-p:ContainerImageTags="dev-chiseled"' -p:ContainerFamily=noble-chiseled-extra -p:ContainerRegistry=registry.hub.docker.com
- name: Build and push Docker release
if: ${{ env.IS_RELEASE == 'true' }}
run: |
dotnet publish src/WebApp/WebApp.csproj /t:MultiArchPublish '-p:ContainerImageTags="${{ env.VERSION }};latest"' -p:ContainerRegistry=registry.hub.docker.com
dotnet publish src/WebApp/WebApp.csproj /t:MultiArchPublish '-p:ContainerImageTags="${{ env.VERSION }}-chiseled;latest-chiseled"' -p:ContainerFamily=noble-chiseled-extra -p:ContainerRegistry=registry.hub.docker.com
github-ref-name: ${{ github.ref }}
sonar-key: 'mu88_Project28'
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-additional-params: '/d:sonar.cs.opencover.reportsPaths=src/Tests/coverage.opencover.xml /s:$GITHUB_WORKSPACE/SonarQube.Analysis.xml'
docker-publish-mode: regular_and_chiseled
docker-publish-project: 'src/WebApp/WebApp.csproj'
docker-username: ${{ secrets.DOCKERHUB_USERNAME }}
docker-token: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build single-file EXE
run: dotnet publish src/WebApp/WebApp.csproj -r win-x64 -p:PublishSingleFile=true --self-contained true
- name: Create ZIP for release
uses: thedoctor0/zip-release@master
if: ${{ env.IS_RELEASE == 'true' }}
if: ${{ steps.mu88-ci-cd.outputs.is-release == 'true' }}
with:
type: 'zip'
filename: ThisIsYourLife.${{ env.VERSION }}.zip
filename: ThisIsYourLife.${{ steps.mu88-ci-cd.outputs.release-version }}.zip
directory: 'src/WebApp/bin/Release/net9.0/win-x64/publish'
- name: Create CHANGELOG
id: changelog
uses: Requarks/changelog-action@v1
if: ${{ env.IS_RELEASE == 'true' }}
if: ${{ steps.mu88-ci-cd.outputs.is-release == 'true' }}
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
tag: ${{ steps.mu88-ci-cd.outputs.release-version }}
excludeTypes: build,docs,other,style,chore(deps)
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: ${{ env.IS_RELEASE == 'true' }}
if: ${{ steps.mu88-ci-cd.outputs.is-release == 'true' }}
with:
files: src/WebApp/bin/Release/net9.0/win-x64/publish/ThisIsYourLife*.zip
tag_name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
tag_name: ${{ steps.mu88-ci-cd.outputs.release-version }}
body: ${{ steps.changelog.outputs.changes }}

0 comments on commit 4bd2ca0

Please sign in to comment.