Skip to content

Build, Test, Deploy #1053

Build, Test, Deploy

Build, Test, Deploy #1053

Workflow file for this run

name: Build, Test, Deploy
on:
pull_request:
paths-ignore:
- '**.md'
branches: ["main"]
push:
branches:
- main
paths-ignore:
- '**.md'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: '0 1 * * *'
env:
# GDN_BINSKIM_TARGET: "./src/sWhetstone.ChatGPT/bin/Release/**.dll"
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TWITTER_CREDS: ${{ secrets.TWITTER_CREDS }}
jobs:
build-and-test:
runs-on: 'windows-latest'
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
steps:
- name: List Environment Variables
run: env
- name: Checkout
uses: actions/checkout@v4
- name: setup-dotnet 8.0
uses: xt0rted/setup-dotnet@v1.5.0
with:
dotnet-version: '8.0'
- name: setup-dotnet 6.0
uses: xt0rted/setup-dotnet@v1.5.0
with:
dotnet-version: '6.0'
- name: Build with dotnet
run: dotnet build ./src --configuration Release
- name: Test
run: dotnet test ./src --no-build --verbosity normal --configuration Release
# Run analyzers
- name: Run Microsoft Security DevOps Analysis
uses: microsoft/security-devops-action@v1
id: msdo
with:
tools: binskim, trivy, antimalware
# Upload alerts to the Security tab
- name: Upload alerts to Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
sbom-generation:
runs-on: 'windows-latest'
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
steps:
- name: List Environment Variables
run: env
- name: Checkout
uses: actions/checkout@v4
- name: setup-dotnet 8.0
uses: xt0rted/setup-dotnet@v1.5.0
with:
dotnet-version: '8.0'
- name: setup-dotnet 6.0
uses: xt0rted/setup-dotnet@v1.5.0
with:
dotnet-version: '6.0'
- name: Install SBOM Tools
run: |
dotnet tool install --global Microsoft.Sbom.DotNetTool
dotnet tool install --global CycloneDX --version 3.0.5
- name: Build with dotnet
run: dotnet build ./src --configuration Release
- name: Generate SPDX SBOM
run: |
md spdxoutput
sbom-tool generate -b spdxoutput -bc ./src -pn Whetstone.ChatGPT -pv 1.8.1 -ps "Whetstone Technologies" -nsb https://sbom.whetstonetechnologies.com -V Verbose
- name: Upload SPDX SBOM Build Artifact
uses: actions/upload-artifact@v4.3.3
with:
path: ./spdxoutput
name: spdx.zip
- name: Generate Full CycloneDX SBOM
run: |
md cyclonedx-full-output
dotnet CycloneDX ./src/Whetstone.ChatGPT.sln -o ./cyclonedx-full-output -j -sv 1.8.1 -st library -dpr -f whetstone.chatgpt.full.bom
- name: Upload Full CycloneDX SBOM Build Artifact
uses: actions/upload-artifact@v4.3.3
with:
path: ./cyclonedx-full-output
name: cyclone-full.zip
- name: Generate Production CycloneDX SBOM
run: |
md cyclonedx-prod-output
dotnet CycloneDX ./src/Whetstone.ChatGPT/Whetstone.ChatGPT.csproj -o ./cyclonedx-prod-output -j -sv 1.8.1 -st library -dpr -r -f whetstone.chatgpt.prod.bom
- name: Upload Production CycloneDX SBOM Build Artifact
uses: actions/upload-artifact@v4.3.3
with:
path: ./cyclonedx-prod-output
name: cyclone-prod.zip
deploy-pages:
needs: [build-and-test, sbom-generation]
runs-on: 'ubuntu-latest'
permissions:
contents: write
steps:
- name: List Environment Variables
run: env
- name: Checkout
uses: actions/checkout@v4
- name: setup-dotnet
uses: xt0rted/setup-dotnet@v1.5.0
with:
dotnet-version: '8.0'
# Install dotnet wasm buildtools workload
- name: Install .NET WASM Build Tools
run: dotnet workload install wasm-tools
# https://ilovedotnet.org/blogs/blazor-wasm-publishing-to-github-pages/
# Publishes Blazor project to the release-folder
- name: Publish .NET Blazor Project
run: dotnet publish src/examples/blazor/Whetstone.ChatGPT.Blazor.App/Whetstone.ChatGPT.Blazor.App/Whetstone.ChatGPT.Blazor.App.csproj -c:Release -p:GHPages=true -p:DefineConstants=GHPAGES -o dist/web --nologo
- name: Change base-tag in index.html from / to whetstone.chatgpt
run: sed -i 's/<base href="\/" \/>/<base href="\/whetstone.chatgpt\/" \/>/g' dist/web/wwwroot/index.html
# copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp dist/web/wwwroot/index.html dist/web/wwwroot/404.html
# add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore)
- name: Add .nojekyll file
run: touch dist/web/wwwroot/.nojekyll
- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
folder: dist/web/wwwroot
branch: gh-pages