Skip to content

Commit 00a0836

Browse files
committed
Fix Chrome Web Store deployment - eliminate secret expansion in conditionals
- Remove direct secret expansion in bash conditional - Use file existence check instead of secret content check - Write secret to file first, then validate file content - Prevents multi-line PEM syntax errors completely - Maintains security while enabling reliable deployment
1 parent acdfbb0 commit 00a0836

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.github/workflows/ci-cd.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,21 @@ jobs:
204204
echo "VERSION=${VERSION}" >> $GITHUB_ENV
205205
206206
# Use verified CRX private key from GitHub Secrets with fallback
207-
# Check if secret exists using a safe method
208-
if [[ -z "${{ secrets.CHROME_CRX_PRIVATE_KEY }}" ]]; then
209-
echo "⚠️ CHROME_CRX_PRIVATE_KEY secret not found"
207+
# Try to write the secret directly to file - if it doesn't exist, this will create an empty file
208+
cat > chrome-extension.pem << 'EOF'
209+
${{ secrets.CHROME_CRX_PRIVATE_KEY }}
210+
EOF
211+
212+
# Check if the file has content (safer than checking the secret directly)
213+
if [[ ! -s chrome-extension.pem ]]; then
214+
echo "⚠️ CHROME_CRX_PRIVATE_KEY secret not found or empty"
210215
echo "🔄 Falling back to generated key for testing"
211216
echo "⚠️ Chrome Web Store will reject this - please add verified key as GitHub Secret"
212217

213218
# Generate temporary key for testing
214219
openssl genrsa -out chrome-extension.pem 2048
215220
echo "🔐 Generated temporary CRX private key for testing"
216221
else
217-
# Write private key from GitHub Secrets to temporary file using heredoc
218-
# This safely handles multi-line PEM content without bash interpretation
219-
cat > chrome-extension.pem << 'EOF'
220-
${{ secrets.CHROME_CRX_PRIVATE_KEY }}
221-
EOF
222222
echo "🔐 Using verified CRX private key from GitHub Secrets"
223223
chmod 600 chrome-extension.pem
224224

0 commit comments

Comments
 (0)