2023-08-13 16:34:10 +00:00
|
|
|
name: Test if Server can be built
|
|
|
|
run-name: ${{ gitea.actor }} is building the Server application
|
2023-08-13 16:52:46 +00:00
|
|
|
on: [ push ]
|
2023-08-13 16:34:10 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-server:
|
2023-11-01 17:42:49 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-08-13 16:34:10 +00:00
|
|
|
steps:
|
2023-11-01 17:42:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 7.0
|
2023-11-01 17:48:39 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
|
|
run: |
|
2023-11-01 17:49:45 +00:00
|
|
|
dotnet build Server -c Release
|
|
|
|
# dotnet test Server.Tests -c Release
|
2023-11-01 17:36:23 +00:00
|
|
|
sonarqube:
|
|
|
|
needs: build-server
|
|
|
|
runs-on: ubuntu-latest
|
2023-11-01 17:45:14 +00:00
|
|
|
if: gitea.ref == 'refs/heads/master'
|
2023-11-01 17:36:23 +00:00
|
|
|
steps:
|
2023-11-01 17:42:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 7.0
|
|
|
|
- name: Install dependencies
|
2023-11-01 18:19:49 +00:00
|
|
|
run: |
|
|
|
|
dotnet restore
|
2023-11-01 18:55:08 +00:00
|
|
|
echo "::add-path::$HOME/.dotnet/tools"
|
2023-11-01 17:42:49 +00:00
|
|
|
- name: Setup Sonarqube Dependencies
|
|
|
|
run: |
|
|
|
|
apt-get update
|
|
|
|
apt-get install --yes openjdk-11-jre
|
|
|
|
dotnet tool install --global dotnet-sonarscanner
|
|
|
|
dotnet tool install --global dotnet-coverage
|
|
|
|
- name: Sonarqube Begin
|
|
|
|
run: |
|
2023-11-01 18:49:37 +00:00
|
|
|
dotnet sonarscanner begin /key:"${{ secrets.SONAR_PROJECT_KEY }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
|
2023-11-01 17:42:49 +00:00
|
|
|
- name: Sonarqube Scan
|
|
|
|
run: |
|
2023-11-01 17:49:45 +00:00
|
|
|
dotnet build Server -c Release
|
2023-11-01 17:42:49 +00:00
|
|
|
# dotnet test --collect "Code Coverage" --logger trx --results-directory "TestsResults"
|
|
|
|
# dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml'
|
|
|
|
- name: Sonarqube End
|
|
|
|
run: |
|
2023-11-01 18:04:10 +00:00
|
|
|
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
|
2023-11-01 19:24:19 +00:00
|
|
|
dependency-track:
|
|
|
|
needs: build-server
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 7.0
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
dotnet restore
|
|
|
|
echo "::add-path::$HOME/.dotnet/tools"
|
|
|
|
- name: Setup Dependency Track Dependencies
|
|
|
|
run: |
|
|
|
|
dotnet tool install --global CycloneDX
|
|
|
|
- name: Generate SBOM
|
|
|
|
run: |
|
2023-11-01 19:57:23 +00:00
|
|
|
dotnet CycloneDX Server/Server.csproj -o . -dgl
|
2023-11-01 19:24:19 +00:00
|
|
|
- name: Upload SBOM
|
|
|
|
uses: https://github.com/DependencyTrack/gh-upload-sbom@v2.0.1
|
|
|
|
with:
|
|
|
|
apiKey: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
|
2023-11-01 19:31:30 +00:00
|
|
|
serverHostname: ${{ secrets.DEPENDENCY_TRACK_URL }}
|
|
|
|
projectName: ${{ secrets.DEPENDENCY_TRACK_PROJECT_NAME }}
|
2023-11-01 19:35:44 +00:00
|
|
|
autoCreate: true
|
2023-11-01 20:04:07 +00:00
|
|
|
# set projectversion to be the branch name
|
2023-11-01 20:08:00 +00:00
|
|
|
projectVersion: "${{ github.ref_name }}"
|
2023-11-01 19:41:17 +00:00
|
|
|
bomFilename: "${{ github.workspace }}/bom.xml"
|
2023-11-03 11:33:20 +00:00
|
|
|
build-push-server-container:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 7.0
|
|
|
|
# Add support for more platforms with QEMU (optional)
|
|
|
|
# https://github.com/docker/setup-qemu-action
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: https://github.com/docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: https://github.com/docker/setup-buildx-action@v3.0.0
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: https://github.com/docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: forge.rainote.dev
|
|
|
|
tags: |
|
|
|
|
Wonderking/Continuity:latest
|
|
|
|
Wonderking/Continuity:${{ github.ref_name }}
|
|
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push
|
|
|
|
uses: https://github.com/docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: ./Server/
|
|
|
|
push: true
|
|
|
|
tags: user/repo:latest
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
|
|
dependency-track-container:
|
|
|
|
needs: build-push-server-container
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 7.0
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
dotnet restore
|
|
|
|
echo "::add-path::$HOME/.dotnet/tools"
|
|
|
|
- name: Setup Dependency Track Dependencies
|
|
|
|
run: |
|
|
|
|
dotnet tool install --global CycloneDX
|
|
|
|
- name: Generate SBOM
|
|
|
|
run: |
|
|
|
|
docker sbom --format cyclonedx-json --output bom.json forge.rainote.dev/Wonderking/Continuity:latest
|
|
|
|
- name: Upload SBOM
|
|
|
|
uses: https://github.com/DependencyTrack/gh-upload-sbom@v2.0.1
|
|
|
|
with:
|
|
|
|
apiKey: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
|
|
|
|
serverHostname: ${{ secrets.DEPENDENCY_TRACK_URL }}
|
|
|
|
projectName: "${{ secrets.DEPENDENCY_TRACK_PROJECT_NAME }}-container"
|
|
|
|
autoCreate: true
|
|
|
|
# set projectversion to be the branch name
|
|
|
|
projectVersion: "${{ github.ref_name }}"
|
|
|
|
bomFilename: "${{ github.workspace }}/bom.xml"
|