# Deployment event fails when ref is a tag

**URL:** <https://drone.discourse.group/t/deployment-event-fails-when-ref-is-a-tag/5505>\
**Category:** Drone Support\
**Created:** [February 8, 2017, 4:23pm UTC](https://drone.discourse.group/t/deployment-event-fails-when-ref-is-a-tag/5505 "2017-02-08T16:23:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![garadox](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/garadox/32/4158_2.png) [@garadox](https://drone.discourse.group/u/garadox)\
**Post date:** [February 8, 2017, 4:23pm UTC](https://drone.discourse.group/t/deployment-event-fails-when-ref-is-a-tag/5505/1 "2017-02-08T16:23:31Z")

</div>

I’m testing out the github deployment api integration, and our deployment model is to tag the repo and then create a new deployment with the API.

If I try this, my clone task fails because drone tries to checkout `/refs/heads/TAG`, which is not valid.

---

<div class="post-metadata">

**Author:** ![fbcbarbosa](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/fbcbarbosa/32/3770_2.png) [@fbcbarbosa](https://drone.discourse.group/u/fbcbarbosa)\
**Post date:** [April 6, 2018, 2:37pm UTC](https://drone.discourse.group/t/deployment-event-fails-when-ref-is-a-tag/5505/2 "2018-04-06T14:37:02Z")

</div>

Didn’t find any newer topic about this so I’m bumping it 🙂 I’ve just got the same issue. The deployment event sends this:

```auto
    "sha": "3ef...",
    "ref": "1.0.0",

```

And then Drone tries to:

```auto
+ git fetch --no-tags origin +refs/heads/1.0.0:
fatal: Couldn't find remote ref refs/heads/1.0.0

```

Wouldn’t it be possible, in case of a deployment event, to use “sha” instead of “ref” when cloning? This works:

```auto
git fetch 3ef...

```

Didn’t look at the code to see how its handled though.

---

<div class="post-metadata">

**Author:** ![fbcbarbosa](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/fbcbarbosa/32/3770_2.png) [@fbcbarbosa](https://drone.discourse.group/u/fbcbarbosa)\
**Post date:** [April 6, 2018, 3:02pm UTC](https://drone.discourse.group/t/deployment-event-fails-when-ref-is-a-tag/5505/3 "2018-04-06T15:02:08Z")

</div>

Trying to deploy a commit ref does not work either… the fetch does not actually fetch the ref, but fetched the master instead:

```auto
+ git fetch --no-tags origin +refs/heads/master:
...
+ git reset --hard -q 3ef...
fatal: Could not parse object '3ef....

```

Although the webhook sent the ref correctly:

```auto
    "sha": "3ef...",
    "ref": "3ef...",

```

And the ref “3ef…” is not even in the master branch. Probably somewhere in the clone logic it decided to get the default branch instead.
