diff --git a/.gitea/workflows/docs.yaml b/.gitea/workflows/docs.yaml new file mode 100644 index 0000000..56ee0b3 --- /dev/null +++ b/.gitea/workflows/docs.yaml @@ -0,0 +1,120 @@ +name: Build documentation +run-name: ${{ gitea.actor }} is building the Wiki documentation +on: [push] + +env: + # Name of module and id separated by a slash + INSTANCE: Wiki/wiki + # Replace HI with the ID of the instance in capital letters + ARTIFACT: webHelpWIKI2-all.zip + # Writerside docker image version + DOCKER_VERSION: 232.10165.1 + ALGOLIA_ARTIFACT: algolia-indexes-wiki.zip + + +jobs: + preprocess: + runs-on: ubuntu-latest + outputs: + sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }} + steps: + - name: Sanitize branch name + id: sanitize + run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')" + + docs: + runs-on: ubuntu-latest + container: registry.jetbrains.team/p/writerside/builder/writerside-builder:${{env.DOCKER_VERSION}} + steps: + - name: Install basic dependencies + run: | + wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash + echo "::add-path::$HOME/.nvm" + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install 18 + nvm use 18 + echo "::add-path::$(dirname $(which npm))" + nvm --version + - name: Check Node.js version + run: | + node -v + npm -v + - name: Checkout repository + uses: https://github.com/actions/checkout@v3 + - name: Build docs + run: | + set -e + export DISPLAY=:99 + Xvfb :99 & + /opt/builder/bin/idea.sh helpbuilderinspect -source-dir . -product ${{env.INSTANCE}} -output-dir artifacts/ || true + echo "Test existing of ${{ env.ARTIFACT }} artifact" + test -e artifacts/${{ env.ARTIFACT }} + - name: rename artifact + run: | + mv artifacts/${{ env.ARTIFACT }} artifacts/wiki.zip + - name: Upload documentation + uses: actions/upload-artifact@v3 + with: + name: wiki.zip + path: artifacts/wiki.zip + retention-days: 14 + - name: Upload algolia-indexes + uses: actions/upload-artifact@v3 + with: + name: algolia-indexes.zip + path: artifacts/${{ env.ALGOLIA_ARTIFACT }} + retention-days: 14 + + build-docs-container: + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + needs: [docs, preprocess] + steps: + - name: Checkout repository + uses: https://github.com/actions/checkout@v3 + - 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: Retrieve docs artifact + uses: actions/download-artifact@v3 + with: + name: wiki.zip + path: ${{ github.workspace }} + - name: Unzip wiki.zip into .public + run: | + mkdir .public + unzip -jo -qq ./wiki.zip/wiki.zip -d .public + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: Wiki.Dockerfile + push: true + tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki + platforms: linux/amd64,linux/arm64 + - name: Build and push to latest + if: github.ref_name == 'master' + uses: docker/build-push-action@v5 + with: + context: . + file: Wiki.Dockerfile + push: true + tags: forge.rainote.dev/${{ github.repository }}:latest-wiki + platforms: linux/amd64, linux/arm64 + + deploy-wiki: + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + needs: [build-docs-container, docs, preprocess] + steps: + - name: Deploy Image to CapRrover + run: | + docker run caprover/cli-caprover:2.2.3 caprover deploy --caproverUrl ${{ secrets.CAPROVER_SERVER }} --appToken ${{ secrets.WIKI_APP_TOKEN }} --imageName forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki -a ${{ secrets.WIKI_APP_NAME }} diff --git a/.gitea/workflows/server.yaml b/.gitea/workflows/server.yaml index 018ea5a..f71cf3d 100644 --- a/.gitea/workflows/server.yaml +++ b/.gitea/workflows/server.yaml @@ -1,16 +1,6 @@ -name: Build, Package and Push Images +name: Build, Package and Push Images run-name: ${{ gitea.actor }} is building the Server application -on: [ push ] - -env: - # Name of module and id separated by a slash - INSTANCE: Wiki/wiki - # Replace HI with the ID of the instance in capital letters - ARTIFACT: webHelpWIKI2-all.zip - # Writerside docker image version - DOCKER_VERSION: 232.10165.1 - ALGOLIA_ARTIFACT: algolia-indexes-wiki.zip - +on: [push] jobs: preprocess: @@ -18,120 +8,23 @@ jobs: outputs: sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }} steps: - - name: Sanitize branch name - id: sanitize - run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')" - - docs: - runs-on: ubuntu-latest - container: registry.jetbrains.team/p/writerside/builder/writerside-builder:${{env.DOCKER_VERSION}} - steps: - - name: Install basic dependencies - run: | - wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash - echo "::add-path::$HOME/.nvm" - export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - nvm install 18 - nvm use 18 - echo "::add-path::$(dirname $(which npm))" - nvm --version - - name: Check Node.js version - run: | - node -v - npm -v - - name: Checkout repository - uses: https://github.com/actions/checkout@v3 - - name: Build docs - run: | - set -e - export DISPLAY=:99 - Xvfb :99 & - /opt/builder/bin/idea.sh helpbuilderinspect -source-dir . -product ${{env.INSTANCE}} -output-dir artifacts/ || true - echo "Test existing of ${{ env.ARTIFACT }} artifact" - test -e artifacts/${{ env.ARTIFACT }} - - name: rename artifact - run: | - mv artifacts/${{ env.ARTIFACT }} artifacts/wiki.zip - - name: Upload documentation - uses: actions/upload-artifact@v3 - with: - name: wiki.zip - path: artifacts/wiki.zip - retention-days: 14 - - name: Upload algolia-indexes - uses: actions/upload-artifact@v3 - with: - name: algolia-indexes.zip - path: artifacts/${{ env.ALGOLIA_ARTIFACT }} - retention-days: 14 - - build-docs-container: - runs-on: ubuntu-latest - container: catthehacker/ubuntu:act-latest - needs: [ docs, preprocess ] - steps: - - name: Checkout repository - uses: https://github.com/actions/checkout@v3 - - 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: Retrieve docs artifact - uses: actions/download-artifact@v3 - with: - name: wiki.zip - path: ${{ github.workspace }} - - name: Unzip wiki.zip into .public - run: | - mkdir .public - unzip -jo -qq ./wiki.zip/wiki.zip -d .public - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: Wiki.Dockerfile - push: true - tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki - platforms: linux/amd64,linux/arm64 - - name: Build and push to latest - if: github.ref_name == 'master' - uses: docker/build-push-action@v5 - with: - context: . - file: Wiki.Dockerfile - push: true - tags: forge.rainote.dev/${{ github.repository }}:latest-wiki - platforms: linux/amd64, linux/arm64 - - deploy-wiki: - runs-on: ubuntu-latest - container: catthehacker/ubuntu:act-latest - needs: [ build-docs-container, docs, preprocess ] - steps: - - name: Deploy Image to CapRrover - run: | - docker run caprover/cli-caprover:2.2.3 caprover deploy --caproverUrl ${{ secrets.CAPROVER_SERVER }} --appToken ${{ secrets.WIKI_APP_TOKEN }} --imageName forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki -a ${{ secrets.WIKI_APP_NAME }} + - name: Sanitize branch name + id: sanitize + run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')" build: runs-on: ubuntu-latest steps: - - 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: | - dotnet build Server -c Release + - 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: | + dotnet build Server -c Release # dotnet test Server.Tests -c Release sonarqube: @@ -139,143 +32,143 @@ jobs: 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: 8.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 + - 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 + 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 }}" + - name: Sonarqube End + run: | + dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" sbom-scan: needs: build 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 - 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: | - 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 + - 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: | + 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" + projectVersion: ${{ github.ref_name }} + bomFilename: ${{ github.workspace }}/bom.xml container-build: runs-on: ubuntu-latest container: catthehacker/ubuntu:act-latest - needs: [ build, preprocess ] + needs: [build, preprocess] steps: - - uses: actions/checkout@v3 - - name: Setup dotnet - uses: https://github.com/actions/setup-dotnet@v3 - with: - dotnet-version: 8.0 + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: https://github.com/actions/setup-dotnet@v3 + with: + dotnet-version: 8.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: ${{ github.server_url }} - username: ${{ github.actor }} - 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/${{ 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: . - file: Server/Dockerfile - push: true - tags: forge.rainote.dev/${{ github.repository }}:latest - platforms: linux/amd64, linux/arm64 + - 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: . + file: Server/Dockerfile + 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: . + file: Server/Dockerfile + push: true + tags: forge.rainote.dev/${{ github.repository }}:latest + platforms: linux/amd64, linux/arm64 container-sbom-scan: - needs: [ container-build, preprocess ] + needs: [container-build, preprocess] 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: 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 + - 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 # set projectversion to be the branch name - projectVersion: "${{ github.ref_name }}" - bomFilename: "${{ github.workspace }}/container-bom.json" + projectVersion: ${{ github.ref_name }} + bomFilename: ${{ github.workspace }}/container-bom.json