Skip to content

Commit 4ccfaf1

Browse files
committed
fix: use postCreate to avoid git-secrets failing on second and subsequent starts
1 parent dc74bf6 commit 4ccfaf1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"USER_GID": "${localEnv:GROUP_ID:}"
1212
}
1313
},
14-
"postAttachCommand": "git-secrets --register-aws; git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt",
14+
// Conditionally register git-secrets to avoid failures when it is already configured
15+
// but continue to fail in the case of genuine unexpected errors
16+
"postCreateCommand": "bash -lc 'if ! git config --get-all secrets.patterns | grep -Fq AKIA; then git-secrets --register-aws; fi; if ! git config --get-all secrets.providers | grep -Fxq \"cat /usr/share/secrets-scanner/nhsd-rules-deny.txt\"; then git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt; fi'",
1517
"mounts": [
1618
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
1719
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",

0 commit comments

Comments
 (0)