Skip to content

CI

CI #1697

Workflow file for this run

name: CI
on:
workflow_dispatch:
inputs:
dispatchDeploy:
description: Deploy if there are changes? ('true')
required: false
default: 'true'
push:
tags:
- 'v/*'
branches:
- release/3.x.x
- release/2.x.x
schedule:
- cron: '23 1 * * *'
pull_request:
jobs:
build:
name: CI
strategy:
fail-fast: false
max-parallel: 1
matrix:
ref: '${{ fromJson((''schedule'' == github.event_name) && ''[ "refs/heads/release/2.x.x", "refs/heads/release/3.x.x" ]'' || format(''[ {0} ]'', toJson(github.ref))) }}'
runs-on: windows-2022
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
ref: ${{ matrix.ref }}
- name: Set CAMI Environment Variables
shell: pwsh
env:
ACTION_REF: ${{ matrix.ref }}
ACTION_DISPATCH_DEPLOY: ${{ github.event.inputs.dispatchDeploy }}
run: |
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/$env:GITHUB_REPOSITORY/gh-actions/SetEnv.ps1" | Invoke-Expression
Write-Output "CAMI_DO_DEPLOY=$env:CAMI_DO_DEPLOY" | Out-File -Append -FilePath $env:GITHUB_ENV
Write-Output "CAMI_VERSION=$env:CAMI_VERSION" | Out-File -Append -FilePath $env:GITHUB_ENV
Write-Output "CAMI_SPEC_HASH=$env:CAMI_SPEC_HASH" | Out-File -Append -FilePath $env:GITHUB_ENV
- name: Install dependencies
run: dotnet restore
- name: Build templates
# For some reason `dotnet build` doesn't find the generated `*.cs` files if we don't do this in a separate step.
run: dotnet build --configuration Release --no-restore --target:BuildTemplates || true
- name: Build
run: dotnet build --configuration Release --no-restore -p:version=$env:CAMI_VERSION
- name: Test
if: ${{ github.event_name != 'pull_request' }}
env:
RGAPI_KEY: ${{ secrets.RGAPI_KEY }}
run: dotnet test --no-restore --verbosity minimal
- name: 'Check Changes & Publish Docs'
shell: pwsh
run: |
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/$env:GITHUB_REPOSITORY/gh-actions/Docs.ps1" | Invoke-Expression
Write-Output "CAMI_DO_DEPLOY=$env:CAMI_DO_DEPLOY" | Out-File -Append -FilePath $env:GITHUB_ENV
Write-Output "CAMI_VERSION=$env:CAMI_VERSION" | Out-File -Append -FilePath $env:GITHUB_ENV
Write-Output "CAMI_SPEC_HASH=$env:CAMI_SPEC_HASH" | Out-File -Append -FilePath $env:GITHUB_ENV
- name: Publish to NuGet
if: ${{ success() && env.CAMI_DO_DEPLOY }}
shell: pwsh
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'
run: dotnet nuget push "src\*\bin\Release\*.$env:CAMI_VERSION.nupkg" --source $env:NUGET_SOURCE --api-key $env:NUGET_KEY --skip-duplicate
- name: Publish to GitHub Packages
if: ${{ success() && env.CAMI_DO_DEPLOY }}
shell: pwsh
env:
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}
NUGET_SOURCE: 'https://nuget.pkg.github.com/MingweiSamuel/index.json'
run: dotnet nuget push "src\*\bin\Release\*.$env:CAMI_VERSION.nupkg" --source $env:NUGET_SOURCE --api-key $env:NUGET_KEY --skip-duplicate