UdasriHasindu commited on
Commit ·
a9bd40e
1
Parent(s): 4e8a9e5
fix: actions
Browse files- .github/workflows/deploy.yml +13 -1
.github/workflows/deploy.yml
CHANGED
|
@@ -30,5 +30,17 @@ jobs:
|
|
| 30 |
git config --global user.name "github-actions[bot]"
|
| 31 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
git push --force space HEAD:main
|
|
|
|
| 30 |
git config --global user.name "github-actions[bot]"
|
| 31 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 32 |
|
| 33 |
+
# Strip accidental CR/LF and surrounding whitespace from the secret
|
| 34 |
+
HF_TOKEN_CLEAN="$(printf '%s' "$HF_TOKEN" | tr -d '\r\n' | xargs)"
|
| 35 |
+
|
| 36 |
+
if [ -z "$HF_TOKEN_CLEAN" ]; then
|
| 37 |
+
echo "HF_TOKEN is empty after sanitization."
|
| 38 |
+
exit 1
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
# URL-encode token in case it includes reserved URL characters
|
| 42 |
+
HF_TOKEN_ENC="$(python -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1], safe=""))' "$HF_TOKEN_CLEAN")"
|
| 43 |
+
|
| 44 |
+
git remote remove space 2>/dev/null || true
|
| 45 |
+
git remote add space "https://${HF_USERNAME}:${HF_TOKEN_ENC}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}"
|
| 46 |
git push --force space HEAD:main
|