continuity/.gitea/workflows/server.yaml
Timothy Schenk 137bc0dac1
Some checks failed
Build and Deploy / build-server (push) Successful in 25s
Build and Deploy / dependency-track (push) Successful in 31s
Build and Deploy / build-push-server-container (push) Failing after 28s
Build and Deploy / dependency-track-container (push) Has been skipped
Build and Deploy / sonarqube (push) Successful in 1m23s
ci: add docker compatible container for dtrack container
2023-11-03 14:53:06 +01:00

140 lines
5.1 KiB
YAML

name: Build and Deploy
run-name: ${{ gitea.actor }} is building the Server application
on: [ push ]
jobs:
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
- name: Build
run: |
dotnet build Server -c Release
# dotnet test Server.Tests -c Release
sonarqube:
needs: build-server
runs-on: ubuntu-latest
if: ${{ github.ref_name }} == 'master'
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 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: |
dotnet sonarscanner begin /key:"${{ secrets.SONAR_PROJECT_KEY }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
- name: Sonarqube Scan
run: |
dotnet build Server -c Release
# dotnet test --collect "Code Coverage" --logger trx --results-directory "TestsResults"
# dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml'
- name: Sonarqube End
run: |
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
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: |
dotnet CycloneDX Server/Server.csproj -o . -dgl
- 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 }}
autoCreate: true
# set projectversion to be the branch name
projectVersion: "${{ github.ref_name }}"
bomFilename: "${{ github.workspace }}/bom.xml"
build-push-server-container:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
needs: build-server
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: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: forge.rainote.dev
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Server/Dockerfile
push: true
tags: forge.rainote.dev/Wonderking/Continuity:latest,forge.rainote.dev/Wonderking/Continuity:${{ github.ref_name }}
platforms: linux/amd64
dependency-track-container:
needs: build-push-server-container
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-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: |
mkdir ~/.docker
curl -sSfL https://raw.githubusercontent.com/docker/sbom-cli-plugin/main/install.sh | sh -s --
- 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.json"