@@ -106,15 +106,10 @@ jobs:
106106 name : Windows Smoke Test
107107 runs-on : windows-latest
108108 steps :
109- # Note: no checkout step. The cookiecutter template directory contains
110- # characters (pipe, quotes) that are illegal on NTFS, so we cannot check
111- # out the repo on Windows. Instead, cookiecutter fetches the template
112- # directly from the remote branch.
113109 - name : Setup uv
114110 uses : astral-sh/setup-uv@v7
115111 with :
116112 python-version : ${{ env.python_version }}
117- # No checkout in this job (NTFS-illegal chars in template dir), so disable cache
118113 enable-cache : false
119114 ignore-empty-workdir : true
120115 - name : Install Task
@@ -126,24 +121,30 @@ jobs:
126121 env :
127122 RUN_POST_HOOK : ' true'
128123 SKIP_GIT_PUSH : ' true'
129- TEMPLATE_REF : ${{ github.event.pull_request.head.sha || github.sha }}
124+ TEMPLATE_REPO : ${{ github.repository }}
125+ TEMPLATE_REF : ${{ github.head_ref || github.ref_name }}
130126 run : |
131127 git config --global user.name "CI Automation"
132128 git config --global user.email "ci@zenable.io"
133129
134- # The template directory name contains NTFS-illegal characters
135- # (double quotes, pipe). Use extract_template_zip.py to safely
136- # extract and rename only the top-level template dir.
137- zipUrl="https://github.com/${{ github.repository }}/archive/${TEMPLATE_REF}.zip"
138- scriptUrl="https://raw.githubusercontent.com/${{ github.repository }}/${TEMPLATE_REF}/scripts/extract_template_zip.py"
139- tmpdir=$(mktemp -d)
140- curl -fsSL "$zipUrl" -o "$tmpdir/template.zip"
141- curl -fsSL "$scriptUrl" -o "$tmpdir/extract_template_zip.py"
142- repoDir=$(python3 "$tmpdir/extract_template_zip.py" "$tmpdir/template.zip" "$tmpdir/src")
143-
144- uvx --with gitpython cookiecutter "$repoDir" --no-input \
145- project_name="ci-test-project" \
146- --output-dir "$RUNNER_TEMP"
130+ # Use the same command as README.md (gh: syntax). On Windows, if the
131+ # default branch still has NTFS-illegal paths (pre-merge), the gh: clone
132+ # fails because cookiecutter clones main first. Fall back to a local
133+ # clone in that case. After merge, the gh: command succeeds directly.
134+ uvx --with gitpython cookiecutter \
135+ "gh:${TEMPLATE_REPO}" \
136+ --checkout "${TEMPLATE_REF}" \
137+ --no-input project_name="ci-test-project" \
138+ --output-dir "$RUNNER_TEMP" \
139+ || {
140+ echo "::warning::gh: clone failed (expected pre-merge on Windows). Using local clone."
141+ template_dir="$RUNNER_TEMP/template-repo"
142+ git clone --no-checkout "https://github.com/${TEMPLATE_REPO}.git" "$template_dir"
143+ git -C "$template_dir" checkout "${TEMPLATE_REF}"
144+ uvx --with gitpython cookiecutter "$template_dir" \
145+ --no-input project_name="ci-test-project" \
146+ --output-dir "$RUNNER_TEMP"
147+ }
147148 - name : Verify generated project
148149 shell : pwsh
149150 run : |
0 commit comments