Skip to content

refactor: remove unused NuGet.Config copy from Dockerfile and simplif… #434

refactor: remove unused NuGet.Config copy from Dockerfile and simplif…

refactor: remove unused NuGet.Config copy from Dockerfile and simplif… #434

Workflow file for this run

name: Build and Push Docker Images
on:
workflow_dispatch:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install frontend dependencies
run: |
cd web-site
npm i
- name: Build frontend
run: |
cd web-site
npm run build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract version from Directory.Packages.props
id: get_version
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
[xml]$xml = Get-Content -Raw 'Directory.Packages.props'
$pg = $xml.Project.PropertyGroup
$versionTemplate = [string]$pg.Version
if ([string]::IsNullOrWhiteSpace($versionTemplate)) { throw 'Version not found in Directory.Packages.props' }
$props = @{}
foreach ($n in $pg.ChildNodes) {
if ($n.NodeType -eq [System.Xml.XmlNodeType]::Element) {
$props[$n.Name] = [string]$n.InnerText
}
}
# Provide concrete TimeStamp (UTC yyyyMMdd) in case used in Version
$props['TimeStamp'] = (Get-Date -AsUTC).ToString('yyyyMMdd')
$unresolved = New-Object System.Collections.Generic.List[string]
$finalVersion = [regex]::Replace($versionTemplate, '\$\(([A-Za-z0-9_.-]+)\)', {
param($m)
$name = $m.Groups[1].Value
if ($props.ContainsKey($name) -and -not [string]::IsNullOrWhiteSpace($props[$name])) { $props[$name] } else { $unresolved.Add($name) | Out-Null; '' }
})
if ($unresolved.Count -gt 0) { Write-Host "[warn] Unresolved version tokens -> $($unresolved -join ', ')" }
if ([string]::IsNullOrWhiteSpace($finalVersion)) { throw 'Resolved version is empty' }
"version=$finalVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
Write-Host "Version template: $versionTemplate"
Write-Host "Final version: $finalVersion"
- name: Build and push koala-wiki
uses: docker/build-push-action@v5
with:
context: .
file: src/KoalaWiki/Dockerfile
platforms: linux/amd64
push: true
tags: |
crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:latest
crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:${{ steps.get_version.outputs.version }}