2023-11-16 13:27:49 +00:00
|
|
|
name: Build, Package and Push Images
|
2023-08-13 16:34:10 +00:00
|
|
|
run-name: ${{ gitea.actor }} is building the Server application
|
2023-11-16 14:02:32 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths-ignore:
|
|
|
|
- Wiki/**
|
|
|
|
- Benchmarks/**
|
|
|
|
- .run/**
|
2023-11-15 12:47:35 +00:00
|
|
|
|
2023-08-13 16:34:10 +00:00
|
|
|
jobs:
|
2023-10-27 17:47:17 +00:00
|
|
|
preprocess:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }}
|
|
|
|
steps:
|
2023-11-16 13:27:49 +00:00
|
|
|
- name: Sanitize branch name
|
|
|
|
id: sanitize
|
|
|
|
run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')"
|
2023-11-16 07:13:12 +00:00
|
|
|
|
2023-11-15 13:25:09 +00:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-11-16 13:27:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 8.0
|
|
|
|
- name: Install dependencies
|
|
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
|
|
run: |
|
2023-11-28 14:35:31 +00:00
|
|
|
dotnet build Continuity.AuthServer -c Release
|
2023-11-16 14:02:32 +00:00
|
|
|
# dotnet test Server.Tests -c Release
|
2023-11-15 13:25:09 +00:00
|
|
|
|
2023-10-27 17:47:17 +00:00
|
|
|
sonarqube:
|
|
|
|
needs: build
|
2024-01-29 07:55:15 +00:00
|
|
|
runs-on: catthehacker/ubuntu:act-latest
|
2023-10-27 17:47:17 +00:00
|
|
|
if: github.ref_name == 'master'
|
|
|
|
steps:
|
2023-11-16 13:27:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 8.0
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
dotnet restore
|
|
|
|
echo "::add-path::$HOME/.dotnet/tools"
|
|
|
|
- name: Setup Sonarqube Dependencies
|
|
|
|
run: |
|
|
|
|
apt-get update
|
2024-01-29 07:48:23 +00:00
|
|
|
apt-get install --yes openjdk-18-jre
|
2023-11-16 13:27:49 +00:00
|
|
|
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: |
|
2023-11-28 14:35:31 +00:00
|
|
|
dotnet build Continuity.AuthServer -c Release
|
2023-11-16 14:02:32 +00:00
|
|
|
# dotnet test --collect "Code Coverage" --logger trx --results-directory "TestsResults"
|
|
|
|
# dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml'
|
2023-11-16 13:27:49 +00:00
|
|
|
- name: Sonarqube End
|
|
|
|
run: |
|
|
|
|
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
|
2023-10-27 17:47:17 +00:00
|
|
|
|
|
|
|
sbom-scan:
|
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-11-16 13:27:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: |
|
|
|
|
7.0
|
|
|
|
8.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-28 14:35:31 +00:00
|
|
|
dotnet CycloneDX Continuity.AuthServer/Continuity.AuthServer.csproj -o . -dgl
|
2023-11-16 13:27:49 +00:00
|
|
|
- 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
|
2023-10-27 17:47:17 +00:00
|
|
|
# set projectversion to be the branch name
|
2023-11-16 13:27:49 +00:00
|
|
|
projectVersion: ${{ github.ref_name }}
|
|
|
|
bomFilename: ${{ github.workspace }}/bom.xml
|
2023-10-27 17:47:17 +00:00
|
|
|
|
|
|
|
container-build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container: catthehacker/ubuntu:act-latest
|
2023-11-16 13:27:49 +00:00
|
|
|
needs: [build, preprocess]
|
2023-10-27 17:47:17 +00:00
|
|
|
steps:
|
2023-11-16 13:27:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 8.0
|
2023-11-16 14:02:32 +00:00
|
|
|
# Add support for more platforms with QEMU (optional)
|
|
|
|
# https://github.com/docker/setup-qemu-action
|
2023-11-16 13:27:49 +00:00
|
|
|
- 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: ${{ github.server_url }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
2023-11-28 14:35:31 +00:00
|
|
|
file: Continuity.AuthServer/Dockerfile
|
2023-11-16 13:27:49 +00:00
|
|
|
push: true
|
|
|
|
tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Build and push to latest
|
|
|
|
if: github.ref_name == 'master'
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
2023-11-28 14:35:31 +00:00
|
|
|
file: Continuity.AuthServer/Dockerfile
|
2023-11-16 13:27:49 +00:00
|
|
|
push: true
|
|
|
|
tags: forge.rainote.dev/${{ github.repository }}:latest
|
|
|
|
platforms: linux/amd64, linux/arm64
|
2023-10-27 17:47:17 +00:00
|
|
|
|
|
|
|
container-sbom-scan:
|
2023-11-16 13:27:49 +00:00
|
|
|
needs: [container-build, preprocess]
|
2023-10-27 17:47:17 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container: catthehacker/ubuntu:act-latest
|
|
|
|
steps:
|
2023-11-16 13:27:49 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup dotnet
|
|
|
|
uses: https://github.com/actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: 8.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: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ github.server_url }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Generate SBOM
|
|
|
|
run: |
|
|
|
|
echo forge.rainote.dev/${{ github.repository }}
|
|
|
|
echo forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}
|
|
|
|
docker pull forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}
|
|
|
|
docker sbom -D forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }} --format cyclonedx-json --output container-bom.json
|
|
|
|
- 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
|
2023-10-27 17:47:17 +00:00
|
|
|
# set projectversion to be the branch name
|
2023-11-16 13:27:49 +00:00
|
|
|
projectVersion: ${{ github.ref_name }}
|
|
|
|
bomFilename: ${{ github.workspace }}/container-bom.json
|
2023-10-27 17:47:17 +00:00
|
|
|
|