gpt4 book ai didi

git - 从 CircleCI 推送到 Heroku 时出现协议(protocol)错误

转载 作者:太空狗 更新时间:2023-10-29 14:46:50 30 4
gpt4 key购买 nike

#./circle.yml

deployment:
acceptance:
branch: master
commands:
- ./script/heroku_deploy.sh thecatch-staging:
timeout: 300

#./script/heroku_deploy.sh

#!/bin/sh -e
APP_NAME=$1

git remote add heroku git@heroku.com:$APP_NAME.git
git fetch heroku
MIGRATION_CHANGES=$(git diff HEAD heroku/master --name-only -- db | wc -l)
echo "$MIGRATION_CHANGES db changes."

PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

# migrations require downtime so enter maintenance mode
if test $MIGRATION_CHANGES -gt 0; then
heroku maintenance:on --app $APP_NAME

# Make sure workers are not running during a migration
heroku scale worker=0 --app $APP_NAME
fi

# deploy code changes (and implicitly restart the app and any running workers)
git push heroku $CIRCLE_SHA1:refs/heads/master

# run database migrations if needed and restart background workers once finished
if test $MIGRATION_CHANGES -gt 0; then
heroku run rake db:migrate db:seed --app $APP_NAME
heroku scale worker=$PREV_WORKERS --app $APP_NAME
heroku restart --app $APP_NAME
fi

heroku run rake cache:flush --app $APP_NAME
heroku maintenance:off --app $APP_NAME

当我推送到 master 时,circleci 运行我的测试,测试通过并且在部署到 Heroku 时出现以下错误:

fatal: protocol error: expected old/new/ref, got 'shallow 0966e85b342cb4daaace954d68c928acf743490f'
fatal: The remote end hung up unexpectedly

完整部署日志:

$ ./script/heroku_deploy.sh thecatch-staging
Warning: Permanently added 'heroku.com,50.19.85.132' (RSA) to the list of known hosts.

Fetching repository, done.
From heroku.com:thecatch-staging
* [new branch] master -> heroku/master
0 db changes.
Warning: Permanently added the RSA host key for IP address '50.19.85.156' to the list of known hosts.

Fetching repository, done.
Unshallowing...
remote: Counting objects: 2126, done.
remote: Compressing objects: 100% (614/614), done.
remote: Total 1810 (delta 1255), reused 1663 (delta 1140)
Receiving objects: 100% (1810/1810), 1006.69 KiB | 330.00 KiB/s, done.
Resolving deltas: 100% (1255/1255), completed with 130 local objects.
Counting objects: 55, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (41/41), 4.40 KiB | 0 bytes/s, done.
Total 41 (delta 27), reused 0 (delta 0)
fatal: protocol error: expected old/new/ref, got 'shallow 0966e85b342cb4daaace954d68c928acf743490f'
fatal: The remote end hung up unexpectedly
./script/heroku_deploy.sh thecatch-staging returned exit code 128action ./script/heroku_deploy.sh thecatch-staging failed

最佳答案

您在代码中使用 git push heroku $CIRCLE_SHA1:refs/heads/master 而不是 git push heroku $CIRCLE_SHA1:master

此外,您正在定义 $CIRCLE_SHA1 变量,但它的值并未在脚本中的任何位置赋值。

更正这两个并检查是否解决了您的问题。

关于git - 从 CircleCI 推送到 Heroku 时出现协议(protocol)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22257422/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com