1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/server/remote/github/fixtures/hooks.go
2021-09-23 18:25:51 +02:00

180 lines
5.2 KiB
Go

// Copyright 2018 Drone.IO Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fixtures
// HookPush is a sample push hook.
// https://developer.github.com/v3/activity/events/types/#pushevent
const HookPush = `
{
"ref": "refs/heads/changes",
"created": false,
"deleted": false,
"head_commit": {
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": ["CHANGELOG.md"],
"removed": [],
"modified": ["app/controller/application.rb"]
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"private": false,
"html_url": "https://github.com/baxterthehacker/public-repo",
"default_branch": "master"
},
"pusher": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"sender": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
}
`
// HookPush is a sample push hook that is marked as deleted, and is expected to
// be ignored.
const HookPushDeleted = `
{
"deleted": true
}
`
// HookPullRequest is a sample hook pull request
// https://developer.github.com/v3/activity/events/types/#pullrequestevent
const HookPullRequest = `
{
"action": "opened",
"number": 1,
"pull_request": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1",
"html_url": "https://github.com/baxterthehacker/public-repo/pull/1",
"number": 1,
"state": "open",
"title": "Update the README with new information",
"user": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"base": {
"label": "baxterthehacker:master",
"ref": "master",
"sha": "9353195a19e45482665306e466c832c46560532d"
},
"head": {
"label": "baxterthehacker:changes",
"ref": "changes",
"sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c"
}
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"private": true,
"html_url": "https://github.com/baxterthehacker/public-repo",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"default_branch": "master"
},
"sender": {
"login": "octocat",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
}
`
// HookPullRequestInvalidAction is a sample hook pull request that has an
// action not equal to synchrize or opened, and is expected to be ignored.
const HookPullRequestInvalidAction = `
{
"action": "reopened",
"number": 1
}
`
// HookPullRequestInvalidState is a sample hook pull request that has a state
// not equal to open, and is expected to be ignored.
const HookPullRequestInvalidState = `
{
"action": "synchronize",
"pull_request": {
"number": 1,
"state": "closed"
}
}
`
// HookPush is a sample deployment hook.
// https://developer.github.com/v3/activity/events/types/#deploymentevent
const HookDeploy = `
{
"deployment": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692",
"id": 710692,
"sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"ref": "master",
"task": "deploy",
"payload": {
},
"environment": "production",
"description": null,
"creator": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"private": true,
"html_url": "https://github.com/baxterthehacker/public-repo",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"default_branch": "master"
},
"sender": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
}
`