homedepot / github-webhook-resource

Concourse resource for remotely managing GitHub webhooks
Apache License 2.0
12 stars 20 forks source link

Hook already exists on this repository #56

Open ianatarewe opened 2 months ago

ianatarewe commented 2 months ago

Bug Report

Tell us about your environment

Please show your full resource configuration:

Job:

# Make webhooks
- name: webhooks
  serial: true
  plan:
  - get: git-repo
    trigger: true
    passed: [set-concourse-configs]
  - put: create-arewe-app-webhook
    resource: github-webhook
    params:
      org: arewe-pnw
      repo: arewe-app
      pipeline: arewe-app
      resource_name: git-repo
      webhook_token: ((github.webhook-secret))
      operation: create
      events: [push]
  - put: create-arewe-app-pull-request-webhook
    resource: github-webhook
    params:
      org: arewe-pnw
      repo: arewe-app
      pipeline: arewe-app
      resource_name: github-pull-request
      webhook_token: ((github.webhook-secret))
      operation: create
      events: [pull_request]
  - put: create-arewe-api-gateway-docker-webhook
    resource: github-webhook
    params:
      org: arewe-pnw
      repo: arewe-api-gateway-docker
      pipeline: arewe-api-gateway-docker
      resource_name: git-repo
      webhook_token: ((github.webhook-secret))
      operation: create
      events: [push]
  - put: create-arewe-api-gateway-docker-pull-request-webhook
    resource: github-webhook
    params:
      org: arewe-pnw
      repo: arewe-api-gateway-docker
      pipeline: arewe-api-gateway-docker
      resource_name: github-pull-request
      webhook_token: ((github.webhook-secret))
      operation: create
      events: [pull_request]

And the resources

resources:
- name: git-repo
  type: git
  icon: github
  source:
    uri: git@github.com:arewe-pnw/initial-concourse.git
    branch: master
    private_key: | 
      ((github.sshkey))
- name: github-webhook
  type: github-webhook-resource
  source:
    github_api: https://api.github.com
    github_token: ((github.token))

resource_types:
- name: github-webhook-resource
  type: docker-image
  source:
    repository: homedepottech/github-webhook-resource
    tag: 1.3.0

Describe the issue

What did you do? Pushed a new version of a pipeline that includes updating webhooks

What did you expect to happen? nothing, (green)

What actually happened? Please include your pipeline's raw output from the github-webhook-resource.

It failed "Hook already exists on this repository

selected worker: concourse-ci-deployment-5ccb7c474f-f875g
Webhook location: https://api.github.com/repos/arewe-pnw/arewe-app/hooks
Target Concourse resource: https://ci.arewe.date/api/v1/teams/initial-pipeline-team/pipelines/arewe-app/resources/git-repo/check/webhook?webhook_token=34QCJmwQiOiJHTbqXYpF

Error while calling Github: StatusCodeError
Response Status: 422
Message: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "Hook",
      "code": "custom",
      "message": "Hook already exists on this repository"
    },
    {
      "resource": "Hook",
      "code": "custom",
      "message": "Invalid config attribute: content-type"
    }
  ],
  "documentation_url": "https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook",
  "status": "422"
}

Do you plan to submit a pull request to fix this bug? no

totahuanocotl commented 3 weeks ago

Might be related to https://github.com/homedepot/github-webhook-resource/pull/55#issuecomment-2299287448