Skip to content

Commit 2cd9328

Browse files
passing hab token with dev packages for automate
Signed-off-by: Peter Arsenault <parsenau@progress.com>
1 parent bb104ae commit 2cd9328

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

.github/actions/automate-container-scan/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ This action provides automated vulnerability scanning for Chef Automate's embedd
2020
uses: chef/common-github-actions/.github/actions/automate-container-scan@main
2121
with:
2222
channel: current
23+
license_id: ${{ secrets.GA_DOWNLOAD_GRYPE_LICENSE_ID }}
24+
hab_auth_token: ${{ secrets.HAB_AUTH_TOKEN }} # Required for dev channel
2325
out_dir: out
2426
```
2527
@@ -48,6 +50,8 @@ jobs:
4850
uses: ./common-github-actions/.github/actions/automate-container-scan
4951
with:
5052
channel: current
53+
license_id: ${{ secrets.GA_DOWNLOAD_GRYPE_LICENSE_ID }}
54+
hab_auth_token: ${{ secrets.HAB_AUTH_TOKEN }}
5155
out_dir: out
5256

5357
- name: Upload scan results
@@ -66,8 +70,12 @@ jobs:
6670
| Input | Description | Required | Default |
6771
|-------|-------------|----------|---------|
6872
| `channel` | Release channel for Chef Automate (`stable` or `current`) | No | `current` |
73+
| `license_id` | Chef download license ID (required for commercial downloads) | Yes | N/A |
74+
| `hab_auth_token` | Habitat Builder Personal Access Token for protected channels (pass via secrets) | No | `""` |
6975
| `out_dir` | Output directory for scan results and logs | No | `out` |
7076

77+
**Note on `hab_auth_token`**: This parameter is **required for the `dev` channel** and other protected Habitat channels that contain packages requiring authentication. The `current` and `stable` channels typically have public packages that don't require authentication. If you see `401 Unauthorized` errors during deployment, ensure you've provided a valid HAB_AUTH_TOKEN.
78+
7179
## Outputs
7280

7381
### Directory Structure

.github/actions/automate-container-scan/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
license_id:
1111
description: "Chef download license ID (required for commercial downloads)"
1212
required: true
13+
hab_auth_token:
14+
description: "Habitat Builder Personal Access Token for protected channels (pass via secrets)"
15+
required: false
16+
default: ""
1317
out_dir:
1418
description: "Output directory for scan results and logs"
1519
required: false
@@ -33,6 +37,7 @@ runs:
3337
CHANNEL: ${{ inputs.channel }}
3438
OUT_DIR: ${{ inputs.out_dir }}
3539
ACTION_DIR: ${{ github.action_path }}
40+
HAB_AUTH_TOKEN: ${{ inputs.hab_auth_token }}
3641

3742
branding:
3843
icon: "shield"

.github/actions/automate-container-scan/run.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,20 @@ deploy_automate() {
113113
log "Deploying Automate (this may take 10-15 minutes)..."
114114
log "Progress will be logged to ${LOGS_DIR}/deploy.log"
115115

116+
# Build docker exec command with optional HAB_AUTH_TOKEN
117+
local docker_exec_cmd="docker exec -w /root"
118+
if [[ -n "${HAB_AUTH_TOKEN:-}" ]]; then
119+
log "HAB_AUTH_TOKEN provided - enabling Habitat authentication"
120+
docker_exec_cmd="${docker_exec_cmd} -e HAB_AUTH_TOKEN=${HAB_AUTH_TOKEN}"
121+
fi
122+
docker_exec_cmd="${docker_exec_cmd} ${CONTAINER_ID} timeout 1800 chef-automate deploy --channel ${CHANNEL} --skip-preflight config.toml --accept-terms-and-mlsa"
123+
116124
# Run deploy with timeout and capture output
117125
# tee streams output to Actions log in real-time while also writing to file
118126
# --skip-preflight: the CLI is always downloaded from the 'current' channel (no 'dev' download URL
119127
# exists), so when deploying --channel dev the preflight CLI version check will always fail because
120128
# dev has a newer build than current. The skip is safe: the CLI is still fully capable of deploying.
121-
if docker exec -w /root "${CONTAINER_ID}" timeout 1800 chef-automate deploy --channel ${CHANNEL} --skip-preflight config.toml --accept-terms-and-mlsa \
122-
2>&1 | tee "${LOGS_DIR}/deploy.log"; then
129+
if eval "${docker_exec_cmd}" 2>&1 | tee "${LOGS_DIR}/deploy.log"; then
123130
log "Automate deployment completed successfully"
124131
else
125132
log "ERROR: Automate deployment failed or timed out"

0 commit comments

Comments
 (0)