Skip to content

Commit 2f4b435

Browse files
committed
fix: error in decoding SECRET_APP_CONFIG
- This issue may fix #215 and #225 - The issue is: 1. On Ubuntu, base64 adds line breaks every 76 characters by default 2. When stored in GitHub Secrets, these newlines cause decoding issues Solution: - In update_config.sh: Use tr -d '\n' to remove newlines (cross-platform compatible with both macOS and Linux) - In workflow files: Add -i flag to ignore invalid characters during decode (Linux only, which is fine since GitHub Actions uses ubuntu-latest) Why these fixes work: 1. Encoding fix (tr -d '\n'): On Ubuntu/Linux, base64 adds line breaks every 76 characters by default. Using tr -d '\n' removes all newlines and is compatible with both macOS and Linux (unlike -w 0 which only works on Linux). 2. Decoding fix (-i flag): The -i flag tells base64 --decode to ignore invalid input characters. This provides resilience against any stray whitespace or other characters that might have been introduced during secret storage.
1 parent 16134ac commit 2f4b435

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
SECRET_ENV_FILE: 'env/.env.local'
147147
run: |
148148
echo "------"
149-
echo $SECRET_APP_CONFIG | base64 --decode > $SECRET_ENV_FILE
149+
echo $SECRET_APP_CONFIG | base64 --decode -i > $SECRET_ENV_FILE
150150
151151
# load the environment
152152
- name: Load the github dotenv file

.github/workflows/docs-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
SECRET_ENV_FILE: 'env/.env.local'
127127
run: |
128128
echo "------"
129-
echo $SECRET_APP_CONFIG | base64 --decode > $SECRET_ENV_FILE
129+
echo $SECRET_APP_CONFIG | base64 --decode -i > $SECRET_ENV_FILE
130130
131131
# load the environment
132132
- name: Load the github dotenv file

scripts/update_config.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ url=$(git config --get remote.origin.url)
66
repo_path=$(echo "$url" | sed -E 's|.*/([^/]+)/([^/.]+)(\.git)?|\1/\2|')
77

88

9-
# update the app configs using a base64 encoding of
9+
# update the app configs using a base64 encoding of
1010
# all the variables
11-
ENC=$(cat env/.env.local | base64)
11+
# Note: Use tr -d '\n' to remove line breaks for cross-platform compatibility
12+
# (Linux base64 adds newlines by default, macOS doesn't)
13+
ENC=$(cat env/.env.local | base64 | tr -d '\n')
1214
gh secret set SECRET_APP_CONFIG --body "$ENC" --repo $repo_path
1315

1416

0 commit comments

Comments
 (0)