Deploy a PR build fails

Hi,

I’ve got everything working as expected, except I cannot deploy from a PR. Steps to reproduce:

  1. Create a branch off master. Add a change. Commit and push to GH.
  2. Create a PR on GH.
  3. Assuming the PR build succeeds, promote it to deploy that build to an environment:
deploy username/repo build environment

I expect the latest commit in the PR to be deployed but I get this error instead:

+ git init
Initialized empty Git repository in /drone/src/github.com/username/repo/.git/
+ git remote add origin https://github.com/username/repo.git
+ git fetch --no-tags origin +refs/pull/1/merge:
From https://github.com/username/repo
 * branch            refs/pull/1/merge -> FETCH_HEAD
+ git reset --hard -q 1c5d042a0d3ac08b609344f9a246ec6f11d7cf13
fatal: Could not parse object '1c5d042a0d3ac08b609344f9a246ec6f11d7cf13'.
exit status 128

The clone task at the beginning of the pipeline is not finding the correct commit. I assume the git reset works differently with PR refs. It’s not a race condition, the deployment fails repeatedly. Any advice or help?

Drone project http://drone.datashaman.com/datashaman/drone-sandbox
Github project https://github.com/datashaman/drone-sandbox

.drone.yml:

pipeline:
  test:
    image: alpine
    commands:
    - echo $${SECRET}
    secrets: [ secret ]
  deploy:
    image: alpine
    commands:
    - echo $${SECRET}
    secrets: [ secret ]
    when:
      event: deployment

Please ensure you read the section about using secrets with pull requests:
http://docs.drone.io/manage-secrets/#pull-requests

You can also see this guide for common problems with secrets:
http://docs.drone.io/secrets-not-working/

If you continue to experience issues with secrets, please provide all of the information requested here:
http://docs.drone.io/secrets-not-working/#still-having-trouble

hi, the secrets mentioned in the drone file have nothing to do with the problem. It’s a red herring. I thought as I posted it that it might be confusing…

Would it not work in all cases to git checkout FETCH_HEAD instead of git reset --hard -q commit?