# Github deployments API does not play well with drone

**URL:** <https://drone.discourse.group/t/github-deployments-api-does-not-play-well-with-drone/10727>\
**Category:** Drone Support\
**Created:** [November 28, 2019, 4:28am UTC](https://drone.discourse.group/t/github-deployments-api-does-not-play-well-with-drone/10727 "2019-11-28T04:28:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carash](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@carash](https://drone.discourse.group/u/carash)\
**Post date:** [November 28, 2019, 4:28am UTC](https://drone.discourse.group/t/github-deployments-api-does-not-play-well-with-drone/10727/1 "2019-11-28T04:28:52Z")

</div>

Hi, I’m new to drone and I have a quick question on drone consuming github deployment events.  
I created a simple pipeline to see what I’m working with which just triggers on any event

```auto
kind: pipeline
type: docker
name: testing

steps:
- name: test
  image: busybox
  commands:
  - printenv

```

but then I tried to trigger it via github deployment, and somehow it tried to clone from a tag ref. Is there something I’m doing wrong? or is this a bug?

```bash
curl -X POST \
  https://api.github.com/repos/ ***/*** /deployments \
  -H 'Authorization: Basic *************************************' \
  -H 'Content-Type: application/json' \
  -d '{
  "ref": " ************************************* 695",
  "auto_merge": false
}'

```

```auto
Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/tags/ ************************************* 695:
fatal: Couldn't find remote ref refs/tags/ ************************************* 695

```

---

<div class="post-metadata">

**Author:** ![genisd](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/genisd/32/3535_2.png) [@genisd](https://drone.discourse.group/u/genisd)\
**Post date:** [November 28, 2019, 12:37pm UTC](https://drone.discourse.group/t/github-deployments-api-does-not-play-well-with-drone/10727/2 "2019-11-28T12:37:35Z")

</div>

Add a filter when the pipeline should trigger.

i.e. for pull\_request at the end of the pipeline:

```auto
trigger:
  event:
    - pull_request

```

or for deployment at the end of the pipeline:

```auto
trigger:
  target:
    - test

```

(this will trigger when deployment towards “test” is triggered).

Note deployment event in github is translated into a “promote” event.

```auto
trigger:
  event:
    - promote

```

---

<div class="post-metadata">

**Author:** ![carash](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@carash](https://drone.discourse.group/u/carash)\
**Post date:** [November 29, 2019, 4:12am UTC](https://drone.discourse.group/t/github-deployments-api-does-not-play-well-with-drone/10727/3 "2019-11-29T04:12:32Z")

</div>

Okay… I tried that… The pipeline now looks like this

```auto
kind: pipeline
type: docker
name: testing

steps:
- name: test
  image: busybox
  commands:
  - printenv

trigger:
  event:
  - promote
  target:
  - production

```

Now the drone tries to get from heads ref… which is still wrong

```bash
curl -X POST \
  https://api.github.com/repos/ ***/*** /deployments \
  -H 'Authorization: Basic *************************************' \
  -H 'Content-Type: application/json' \
  -d '{
  "ref": " ************************************* 145",
  "auto_merge": false
}'

```

```auto
Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/ ************************************* 145:
fatal: Couldn't find remote ref refs/heads/ ************************************* 145

```

and when I tried to use a head ref as the target… it just appends a `refs/heads/` as a prefix

```bash
curl -X POST \
  https://api.github.com/repos/ ***/*** /deployments \
  -H 'Authorization: Basic *************************************' \
  -H 'Content-Type: application/json' \
  -d '{
  "ref": "refs/heads/test-triggers",
  "auto_merge": false
}'

```

```auto
Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/refs/heads/test-triggers:
fatal: Couldn't find remote ref refs/heads/refs/heads/test-triggers

```

I’m starting to think that this is an actual bug… and I should put this under the bugs category
