Bizarre workaround needed for github deployment

Hi, I’m using Hakyll (specifically a repo forked from dr-hakyll) for my site. I’m using master as the code branch and gh-pages for the site itself. I spent a day and a half trying to figure out why my push was failing to authenticate, and I finally figured out that CircleCI was trying to use an https url to push to instead of an ssh url.

When I add a totally useless git config --global -l right before the other deployment commands, it “fixes” the problem (and displays the config to replace https with ssh). This seems buggy, but is there maybe something I did wrong?

Here’s my circle.yml:

machine:

  timezone:
    America/Denver

dependencies:

  cache_directories:
    - "~/.stack"

  override:
    - curl -sSL https://get.haskellstack.org/ | sh
    - stack setup
    - stack build --no-system-ghc --install-ghc --only-dependencies

test:

  override:
    - stack build --no-system-ghc --install-ghc

  post:
    - git submodule init
    - git submodule update
    - cd _site/ && git checkout gh-pages
    - stack exec dr-hakyll build

deployment:

  production:
    branch: master
    commands:
      - git config --global -l #<= totally unnecessary, but "fixes" problem?
      - git config --global user.email circleci@circleci
      - git config --global user.name CircleCI
      - cd _site/ && git status
      - cd _site/ && git add --all
      - cd _site/ && git commit -m "Update (`date '+%F %T %Z'`) [ci skip]" || true
      - cd _site/ && git push origin gh-pages
      - git status
      - git add _site/
      - git commit -m "Update _site (`date '+%F %T %Z'`) [ci skip]" || true
      - git push origin master

I should note that this circle.yml was cribbed from at least two other people who are using github to host a site. I haven’t done much differently from them.

THANK YOU! I have spent way too much time trying to figure out why npm version or git push doesn’t use the SSH key I added.

It seems like this is something that should be clarified in the documentation.

@benjamincharity Are you also using the same dr-hakyll static site generator?

Nope. Just using NPM and git commands.

deployment:
  feature:
    branch: master
    commands:
      - ./config/npm-deploy-feature.sh

And the script just has items like:

lastTag=$(git describe --tags $(git rev-list --tags --max-count=1))
npm version $lastTag-feature.$CIRCLE_BUILD_NUM
git push --tags

Thanks! Just to add to this, it works extremely well when deploying a react app onto github pages using gh-pages:

general:
    branches:
    only:
      - react-rewrite
deployment:
  production:
    branch: react-rewrite
    commands:
      - git config --global -l
      - git config --global user.email circleci@circleci
      - git config --global user.name CircleCI
      - npm run deploy

Could everyone try npm run deploy and let us know if this resolves the issue?

Super weird that CircleCI does not pick up the official environment variables. (https://git-scm.com/book/gr/v2/Git-Internals-Environment-Variables#_committing)

Thats my workaround:

deployment:
  production:
    branch: development
    commands:
      - git config --global user.email "$GIT_AUTHOR_EMAIL"
      - git config --global user.name "$GIT_AUTHOR_NAME"
      - npm run deploy

The git config --global -l was not neccessary for me to get it working.

@zzak: so no, it is not npm run deploy, it is the manually setting of the git credentials which actually fixed the issue. The npm script is different for everyone.