# Deploy a PR build fails

**URL:** <https://drone.discourse.group/t/deploy-a-pr-build-fails/10640>\
**Category:** Drone Support\
**Created:** [November 18, 2017, 12:45pm UTC](https://drone.discourse.group/t/deploy-a-pr-build-fails/10640 "2017-11-18T12:45:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![datashaman](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/datashaman/32/3966_2.png) [@datashaman](https://drone.discourse.group/u/datashaman)\
**Post date:** [November 18, 2017, 12:45pm UTC](https://drone.discourse.group/t/deploy-a-pr-build-fails/10640/1 "2017-11-18T12:45:56Z")

</div>

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:

```auto
deploy username/repo build environment

```

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

```auto
+ 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?

---

<div class="post-metadata">

**Author:** ![datashaman](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/datashaman/32/3966_2.png) [@datashaman](https://drone.discourse.group/u/datashaman)\
**Post date:** [November 18, 2017, 1:10pm UTC](https://drone.discourse.group/t/deploy-a-pr-build-fails/10640/2 "2017-11-18T13:10:46Z")

</div>

Drone project [http://drone.datashaman.com/datashaman/drone-sandbox](http://drone.datashaman.com/datashaman/drone-sandbox)  
Github project [https://github.com/datashaman/drone-sandbox](https://github.com/datashaman/drone-sandbox)

**.drone.yml** :

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

```

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [November 18, 2017, 5:04pm UTC](https://drone.discourse.group/t/deploy-a-pr-build-fails/10640/3 "2017-11-18T17:04:13Z")

</div>

Please ensure you read the section about using secrets with pull requests:  
[http://docs.drone.io/manage-secrets/#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/](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](http://docs.drone.io/secrets-not-working/#still-having-trouble)

---

<div class="post-metadata">

**Author:** ![datashaman](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/datashaman/32/3966_2.png) [@datashaman](https://drone.discourse.group/u/datashaman)\
**Post date:** [November 19, 2017, 7:01am UTC](https://drone.discourse.group/t/deploy-a-pr-build-fails/10640/4 "2017-11-19T07:01:49Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![datashaman](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/datashaman/32/3966_2.png) [@datashaman](https://drone.discourse.group/u/datashaman)\
**Post date:** [November 19, 2017, 7:22am UTC](https://drone.discourse.group/t/deploy-a-pr-build-fails/10640/5 "2017-11-19T07:22:40Z")

</div>

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