@@ -119,7 +119,7 @@ jobs:
119119 with :
120120 repo-token : ${{ secrets.GITHUB_TOKEN }}
121121 - name : Generate project from template
122- shell : pwsh
122+ shell : bash
123123 env :
124124 RUN_POST_HOOK : ' true'
125125 SKIP_GIT_PUSH : ' true'
@@ -128,35 +128,17 @@ jobs:
128128 git config --global user.name "CI Automation"
129129 git config --global user.email "ci@zenable.io"
130130
131- # The template directory name contains double-quote characters which
132- # are fundamentally illegal on NTFS. Download the zip and extract with
133- # Python, replacing " with ' in paths during extraction. This is safe
134- # because Jinja2 treats single and double quotes identically, so
135- # replace(" ", "") and replace(' ', '') produce the same output.
136- $zipUrl = "https://github.com/${{ github.repository }}/archive/$env:TEMPLATE_REF.zip"
137- $zipPath = Join-Path $env:RUNNER_TEMP "template.zip"
138- $extractDir = Join-Path $env:RUNNER_TEMP "template-src"
139- Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath
140-
141- python -c @"
142- import zipfile, os, sys
143- zf = zipfile.ZipFile(sys.argv[1])
144- dest = sys.argv[2]
145- for info in zf.infolist():
146- name = info.filename
147- if os.name == 'nt':
148- name = name.replace(chr(34), chr(39))
149- target = os.path.join(dest, name.replace('/', os.sep).rstrip(os.sep))
150- if info.is_dir():
151- os.makedirs(target, exist_ok=True)
152- else:
153- os.makedirs(os.path.dirname(target), exist_ok=True)
154- with zf.open(info) as src, open(target, 'wb') as dst:
155- dst.write(src.read())
156- print(os.path.join(dest, os.listdir(dest)[0]))
157- "@ $zipPath $extractDir | Set-Variable templateDir
131+ # The cookiecutter template directory name contains characters that
132+ # are illegal on NTFS (double quotes, pipe). Use Git Bash (available
133+ # on all Windows runners) which operates on a POSIX compatibility
134+ # layer where these characters are valid.
135+ zipUrl="https://github.com/${{ github.repository }}/archive/${TEMPLATE_REF}.zip"
136+ tmpdir=$(mktemp -d)
137+ curl -fsSL "$zipUrl" -o "$tmpdir/template.zip"
138+ unzip -q "$tmpdir/template.zip" -d "$tmpdir/src"
139+ templateDir="$tmpdir/src/$(ls "$tmpdir/src")"
158140
159- uvx --with gitpython cookiecutter $templateDir.Trim() --no-input --output-dir "$env: RUNNER_TEMP"
141+ uvx --with gitpython cookiecutter " $templateDir" --no-input --output-dir "$RUNNER_TEMP"
160142 - name : Verify generated project
161143 shell : pwsh
162144 run : |
0 commit comments