hit_webhook.sh (7699B)
1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 # Load env vars if not already set 5 if [ -f "$(dirname "$0")/env.example" ]; then 6 source "$(dirname "$0")/env.example" 7 fi 8 9 BODY='{ 10 "ref": "refs/heads/develop", 11 "before": "bd3dbf35ac3aef03ff16701906dc5c164bfad951", 12 "after": "bd3dbf35ac3aef03ff16701906dc5c164bfad951", 13 "compare_url": "https://gitea.midpathsoftware.com/midpath/midpathsoftware_com/compare/bd3dbf35ac3aef03ff16701906dc5c164bfad951...bd3dbf35ac3aef03ff16701906dc5c164bfad951", 14 "commits": [ 15 { 16 "id": "bd3dbf35ac3aef03ff16701906dc5c164bfad951", 17 "message": "remove bolmitra (!135)\n\nReviewed-on: https://gitea.midpathsoftware.com/midpath/midpathsoftware_com/pulls/135\nCo-authored-by: Arjoonn Sharma <arjoonn@midpathsoftware.com>\nCo-committed-by: Arjoonn Sharma <arjoonn@midpathsoftware.com>\n", 18 "url": "https://gitea.midpathsoftware.com/midpath/midpathsoftware_com/commit/bd3dbf35ac3aef03ff16701906dc5c164bfad951", 19 "author": { 20 "name": "Arjoonn Sharma", 21 "email": "arjoonn@midpathsoftware.com", 22 "username": "" 23 }, 24 "committer": { 25 "name": "arjoonn", 26 "email": "arjoonn@noreply.localhost", 27 "username": "" 28 }, 29 "verification": null, 30 "timestamp": "0001-01-01T00:00:00Z", 31 "added": null, 32 "removed": null, 33 "modified": null 34 } 35 ], 36 "total_commits": 1, 37 "head_commit": { 38 "id": "bd3dbf35ac3aef03ff16701906dc5c164bfad951", 39 "message": "remove bolmitra (!135)\n\nReviewed-on: https://gitea.midpathsoftware.com/midpath/midpathsoftware_com/pulls/135\nCo-authored-by: Arjoonn Sharma <arjoonn@midpathsoftware.com>\nCo-committed-by: Arjoonn Sharma <arjoonn@midpathsoftware.com>\n", 40 "url": "https://gitea.midpathsoftware.com/midpath/midpathsoftware_com/commit/bd3dbf35ac3aef03ff16701906dc5c164bfad951", 41 "author": { 42 "name": "Arjoonn Sharma", 43 "email": "arjoonn@midpathsoftware.com", 44 "username": "" 45 }, 46 "committer": { 47 "name": "arjoonn", 48 "email": "arjoonn@noreply.localhost", 49 "username": "" 50 }, 51 "verification": null, 52 "timestamp": "0001-01-01T00:00:00Z", 53 "added": null, 54 "removed": null, 55 "modified": null 56 }, 57 "repository": { 58 "id": 117, 59 "owner": { 60 "id": 3, 61 "login": "midpath", 62 "login_name": "", 63 "source_id": 0, 64 "full_name": "", 65 "email": "midpath@noreply.localhost", 66 "avatar_url": "https://gitea.midpathsoftware.com/avatars/e0cd95ab87f10b5d47ac695e8c2249c277923d365269152221e775216340bbc9", 67 "html_url": "https://gitea.midpathsoftware.com/midpath", 68 "language": "", 69 "is_admin": false, 70 "last_login": "0001-01-01T00:00:00Z", 71 "created": "2022-09-16T18:24:04Z", 72 "restricted": false, 73 "active": false, 74 "prohibit_login": false, 75 "location": "", 76 "website": "", 77 "description": "", 78 "visibility": "private", 79 "followers_count": 0, 80 "following_count": 0, 81 "starred_repos_count": 0, 82 "username": "midpath" 83 }, 84 "name": "midpathsoftware_com", 85 "full_name": "midpath/midpathsoftware_com", 86 "description": "", 87 "empty": false, 88 "private": true, 89 "fork": false, 90 "template": false, 91 "parent": null, 92 "mirror": false, 93 "size": 543150, 94 "language": "", 95 "languages_url": "https://gitea.midpathsoftware.com/api/v1/repos/midpath/midpathsoftware_com/languages", 96 "html_url": "https://gitea.midpathsoftware.com/midpath/midpathsoftware_com", 97 "url": "https://gitea.midpathsoftware.com/api/v1/repos/midpath/midpathsoftware_com", 98 "link": "", 99 "ssh_url": "git@gitea.midpathsoftware.com:midpath/midpathsoftware_com.git", 100 "clone_url": "https://gitea.midpathsoftware.com/midpath/midpathsoftware_com.git", 101 "original_url": "", 102 "website": "", 103 "stars_count": 0, 104 "forks_count": 0, 105 "watchers_count": 2, 106 "open_issues_count": 0, 107 "open_pr_counter": 0, 108 "release_counter": 0, 109 "default_branch": "develop", 110 "archived": false, 111 "created_at": "2023-08-29T13:35:20Z", 112 "updated_at": "2026-04-24T13:26:33Z", 113 "archived_at": "1970-01-01T00:00:00Z", 114 "permissions": { 115 "admin": false, 116 "push": false, 117 "pull": false 118 }, 119 "has_issues": true, 120 "external_tracker": { 121 "external_tracker_url": "https://gitea.midpathsoftware.com/midpath/tasks/issues?labels=301", 122 "external_tracker_format": "https://gitea.midpathsoftware.com/midpath/tasks/issues/{index}", 123 "external_tracker_style": "numeric", 124 "external_tracker_regexp_pattern": "" 125 }, 126 "has_wiki": false, 127 "has_pull_requests": true, 128 "has_projects": false, 129 "projects_mode": "all", 130 "has_releases": false, 131 "has_packages": false, 132 "has_actions": false, 133 "ignore_whitespace_conflicts": false, 134 "allow_merge_commits": true, 135 "allow_rebase": true, 136 "allow_rebase_explicit": true, 137 "allow_squash_merge": true, 138 "allow_fast_forward_only_merge": false, 139 "allow_rebase_update": true, 140 "default_delete_branch_after_merge": true, 141 "default_merge_style": "squash", 142 "default_allow_maintainer_edit": false, 143 "avatar_url": "", 144 "internal": false, 145 "mirror_interval": "", 146 "object_format_name": "sha1", 147 "mirror_updated": "0001-01-01T00:00:00Z", 148 "repo_transfer": null, 149 "topics": [], 150 "licenses": null 151 }, 152 "pusher": { 153 "id": 1, 154 "login": "arjoonn", 155 "login_name": "", 156 "source_id": 0, 157 "full_name": "", 158 "email": "arjoonn@noreply.localhost", 159 "avatar_url": "https://gitea.midpathsoftware.com/avatars/eecdccaa8dd90641c37410078405e28a1eeb848c7ba2cbd2305180422cd00b40", 160 "html_url": "https://gitea.midpathsoftware.com/arjoonn", 161 "language": "", 162 "is_admin": false, 163 "last_login": "0001-01-01T00:00:00Z", 164 "created": "2022-09-16T18:07:08Z", 165 "restricted": false, 166 "active": false, 167 "prohibit_login": false, 168 "location": "Jaipur", 169 "website": "", 170 "description": "", 171 "visibility": "private", 172 "followers_count": 0, 173 "following_count": 0, 174 "starred_repos_count": 5, 175 "username": "arjoonn" 176 }, 177 "sender": { 178 "id": 1, 179 "login": "arjoonn", 180 "login_name": "", 181 "source_id": 0, 182 "full_name": "", 183 "email": "arjoonn@noreply.localhost", 184 "avatar_url": "https://gitea.midpathsoftware.com/avatars/eecdccaa8dd90641c37410078405e28a1eeb848c7ba2cbd2305180422cd00b40", 185 "html_url": "https://gitea.midpathsoftware.com/arjoonn", 186 "language": "", 187 "is_admin": false, 188 "last_login": "0001-01-01T00:00:00Z", 189 "created": "2022-09-16T18:07:08Z", 190 "restricted": false, 191 "active": false, 192 "prohibit_login": false, 193 "location": "Jaipur", 194 "website": "", 195 "description": "", 196 "visibility": "private", 197 "followers_count": 0, 198 "following_count": 0, 199 "starred_repos_count": 5, 200 "username": "arjoonn" 201 } 202 }' 203 204 SIG256=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$GITEA_WEBHOOK_SECRET" | awk '{print $2}') 205 SIG1=$(printf '%s' "$BODY" | openssl dgst -sha1 -hmac "$GITEA_WEBHOOK_SECRET" | awk '{print $2}') 206 207 curl -X POST http://localhost:8080/webhook \ 208 -H "Content-Type: application/json" \ 209 -H "X-GitHub-Delivery: 6a542f57-3d50-431a-a30d-f87f29933729" \ 210 -H "X-GitHub-Event: push" \ 211 -H "X-GitHub-Event-Type: push" \ 212 -H "X-Gitea-Delivery: 6a542f57-3d50-431a-a30d-f87f29933729" \ 213 -H "X-Gitea-Event: push" \ 214 -H "X-Gitea-Event-Type: push" \ 215 -H "X-Gitea-Signature: $SIG256" \ 216 -H "X-Gogs-Delivery: 6a542f57-3d50-431a-a30d-f87f29933729" \ 217 -H "X-Gogs-Event: push" \ 218 -H "X-Gogs-Event-Type: push" \ 219 -H "X-Gogs-Signature: $SIG256" \ 220 -H "X-Hub-Signature: sha1=$SIG1" \ 221 -H "X-Hub-Signature-256: sha256=$SIG256" \ 222 -d "$BODY"