Skip to content

Commit 6ae4aba

Browse files
Nik08Copilot
authored andcommitted
fix: preserve HAB_AUTH_TOKEN through sudo and fix Windows hab PATH
Linux/macOS: `sudo hab pkg install` was dropping the HAB_AUTH_TOKEN environment variable because sudo does not preserve env vars by default. The token was correctly set via `export`, but the hab process running under sudo never received it, resulting in 401 Unauthorized from Builder. Fix: use `sudo -E` to preserve the environment across all three `sudo hab pkg install` invocations (Linux build install, Linux download, macOS download). Windows: hab binary was installed to C:\ProgramData\Habitat but that directory was never added to GITHUB_PATH in the Configure Habitat step, causing subsequent steps to fail with 'hab is not recognized'. Fix: add C:\ProgramData\Habitat to GITHUB_PATH. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Nikita Mathur <nikita.mathur@progress.com>
1 parent e79e265 commit 6ae4aba

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

.github/workflows/grype-hab-package-scan.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
hartifacts=$(ls results/*.hart)
153153
if [ -f "$hartifacts" ]; then
154154
echo "Built package artifact: $hartifacts"
155-
sudo hab pkg install $hartifacts
155+
sudo -E hab pkg install $hartifacts
156156
else
157157
echo "Error: No .hart file found in results/"
158158
exit 1
@@ -189,7 +189,7 @@ jobs:
189189
PACKAGE="${PACKAGE}/${{ inputs.hab_release }}"
190190
fi
191191
192-
INSTALL_CMD="sudo hab pkg install ${PACKAGE}"
192+
INSTALL_CMD="sudo -E hab pkg install ${PACKAGE}"
193193
194194
if [ -n "${{ inputs.hab_channel }}" ]; then
195195
INSTALL_CMD="${INSTALL_CMD} --channel ${{ inputs.hab_channel }}"
@@ -298,6 +298,7 @@ jobs:
298298
echo "HAB_LICENSE=accept-no-persist" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
299299
New-Item -ItemType Directory -Force -Path "C:\hab\accepted-licenses"
300300
New-Item -ItemType File -Force -Path "C:\hab\accepted-licenses\habitat"
301+
echo "C:\ProgramData\Habitat" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
301302
302303
- name: Checkout code
303304
if: ${{ inputs.build_package == true }}
@@ -582,7 +583,7 @@ jobs:
582583
PACKAGE="${PACKAGE}/${{ inputs.hab_release }}"
583584
fi
584585
585-
INSTALL_CMD="sudo hab pkg install ${PACKAGE}"
586+
INSTALL_CMD="sudo -E hab pkg install ${PACKAGE}"
586587
587588
if [ -n "${{ inputs.hab_channel }}" ]; then
588589
INSTALL_CMD="${INSTALL_CMD} --channel ${{ inputs.hab_channel }}"

0 commit comments

Comments
 (0)