Fix Gitea NuGet workflow to run without Node-based checkout in container.
Some checks failed
NuGet Publish / build-and-pack (push) Failing after 3s
NuGet Publish / publish-to-gitea (push) Has been skipped

This commit is contained in:
Joseph Doherty
2026-02-20 13:40:15 -05:00
parent 528939d3a0
commit 2b0d66b7b5

View File

@@ -11,8 +11,19 @@ jobs:
container: container:
image: mcr.microsoft.com/dotnet/sdk:10.0 image: mcr.microsoft.com/dotnet/sdk:10.0
steps: steps:
- name: Checkout - name: Checkout Repository
uses: actions/checkout@v4 run: |
set -euo pipefail
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
if [ -n "${GITHUB_TOKEN:-}" ]; then
REPO_URL="${GITHUB_SERVER_URL/https:\/\//https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@}/${GITHUB_REPOSITORY}.git"
fi
git init .
git config --global --add safe.directory "$PWD"
git remote add origin "$REPO_URL"
git fetch --depth=1 origin "${GITHUB_SHA}"
git checkout --detach FETCH_HEAD
- name: Restore - name: Restore
run: dotnet restore CBDD.slnx run: dotnet restore CBDD.slnx
@@ -28,21 +39,29 @@ jobs:
dotnet pack src/CBDD.Core/ZB.MOM.WW.CBDD.Core.csproj -c Release -o nupkgs --no-build dotnet pack src/CBDD.Core/ZB.MOM.WW.CBDD.Core.csproj -c Release -o nupkgs --no-build
dotnet pack src/CBDD.SourceGenerators/ZB.MOM.WW.CBDD.SourceGenerators.csproj -c Release -o nupkgs --no-build dotnet pack src/CBDD.SourceGenerators/ZB.MOM.WW.CBDD.SourceGenerators.csproj -c Release -o nupkgs --no-build
- name: Upload Package Artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: nupkgs/*.nupkg
publish-to-gitea: publish-to-gitea:
needs: build-and-pack needs: build-and-pack
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ gitea.ref == 'refs/heads/main' && secrets.GITEA_NUGET_USERNAME != '' && secrets.GITEA_NUGET_TOKEN != '' }} if: ${{ github.ref == 'refs/heads/main' }}
container: container:
image: mcr.microsoft.com/dotnet/sdk:10.0 image: mcr.microsoft.com/dotnet/sdk:10.0
env:
GITEA_NUGET_USERNAME: ${{ secrets.GITEA_NUGET_USERNAME }}
GITEA_NUGET_TOKEN: ${{ secrets.GITEA_NUGET_TOKEN }}
steps: steps:
- name: Checkout - name: Checkout Repository
uses: actions/checkout@v4 run: |
set -euo pipefail
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
if [ -n "${GITHUB_TOKEN:-}" ]; then
REPO_URL="${GITHUB_SERVER_URL/https:\/\//https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@}/${GITHUB_REPOSITORY}.git"
fi
git init .
git config --global --add safe.directory "$PWD"
git remote add origin "$REPO_URL"
git fetch --depth=1 origin "${GITHUB_SHA}"
git checkout --detach FETCH_HEAD
- name: Restore - name: Restore
run: dotnet restore CBDD.slnx run: dotnet restore CBDD.slnx
@@ -60,15 +79,26 @@ jobs:
- name: Configure Gitea NuGet Source - name: Configure Gitea NuGet Source
run: | run: |
set -euo pipefail
USERNAME="${GITEA_NUGET_USERNAME:-${GITHUB_ACTOR}}"
TOKEN="${GITEA_NUGET_TOKEN:-${GITHUB_TOKEN:-}}"
if [ -z "$TOKEN" ]; then
echo "No token available for NuGet publish"
exit 1
fi
dotnet nuget remove source gitea >/dev/null 2>&1 || true
dotnet nuget add source \ dotnet nuget add source \
"https://gitea.dohertylan.com/api/packages/dohertj2/nuget/index.json" \ "${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/nuget/index.json" \
--name gitea \ --name gitea \
--username "${{ secrets.GITEA_NUGET_USERNAME }}" \ --username "$USERNAME" \
--password "${{ secrets.GITEA_NUGET_TOKEN }}" \ --password "$TOKEN" \
--store-password-in-clear-text --store-password-in-clear-text
- name: Publish Packages - name: Publish Packages
run: | run: |
set -euo pipefail
for pkg in nupkgs/*.nupkg; do for pkg in nupkgs/*.nupkg; do
if [ -f "$pkg" ] && [[ "$pkg" != *.snupkg ]]; then if [ -f "$pkg" ] && [[ "$pkg" != *.snupkg ]]; then
dotnet nuget push "$pkg" --source gitea --skip-duplicate dotnet nuget push "$pkg" --source gitea --skip-duplicate