2024-07-14 20:13:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
function main() {
|
2024-07-16 01:02:30 +00:00
|
|
|
local payload sha256signature sha1signature
|
|
|
|
payload=$(base64 -d <<EOF
|
|
|
|
ewogICJyZWYiOiAicmVmcy9oZWFkcy9tYWluIiwKICAiYmVmb3JlIjogIjQ1NTViYjY4OTRhNTlkOGZiYTg4OTk3YjUxNzYxZjBmZWIzNDQyY2EiLAogICJhZnRlciI6ICJiOTFmNjM4ODRhZmQ2Y2EwMGMwNzZhMGY5MGNlNWIzNzEzYWZjYzkyIiwKICAiY29tcGFyZV91cmwiOiAiaHR0cHM6Ly9jb2RlLmZpenouYnV6ei90YWxleGFuZGVyL3dlYmhvb2tfYnJpZGdlL2NvbXBhcmUvNDU1NWJiNjg5NGE1OWQ4ZmJhODg5OTdiNTE3NjFmMGZlYjM0NDJjYS4uLmI5MWY2Mzg4NGFmZDZjYTAwYzA3NmEwZjkwY2U1YjM3MTNhZmNjOTIiLAogICJjb21taXRzIjogWwogICAgewogICAgICAiaWQiOiAiYjkxZjYzODg0YWZkNmNhMDBjMDc2YTBmOTBjZTViMzcxM2FmY2M5MiIsCiAgICAgICJtZXNzYWdlIjogIndpcFxuIiwKICAgICAgInVybCI6ICJodHRwczovL2NvZGUuZml6ei5idXp6L3RhbGV4YW5kZXIvd2ViaG9va19icmlkZ2UvY29tbWl0L2I5MWY2Mzg4NGFmZDZjYTAwYzA3NmEwZjkwY2U1YjM3MTNhZmNjOTIiLAogICAgICAiYXV0aG9yIjogewogICAgICAgICJuYW1lIjogIlRvbSBBbGV4YW5kZXIiLAogICAgICAgICJlbWFpbCI6ICJ0b21AZml6ei5idXp6IiwKICAgICAgICAidXNlcm5hbWUiOiAiIgogICAgICB9LAogICAgICAiY29tbWl0dG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owMCIsCiAgICAiYWRkZWQiOiBbXSwKICAgICJyZW1vdmVkIjogW10sCiAgICAibW9kaWZpZWQiOiBbCiAgICAgICJDYXJnby5sb2NrIiwKICAgICAgIkNhcmdvLnRvbWwiLAogICAgICAic3JjL3dlYmhvb2sucnMiCiAgICBdCiAgfSwKICAicmVwb3NpdG9yeSI6IHsKICAgICJpZCI6IDIxLAogICAgIm93bmVyIjogewogICAgICAiaWQiOiAxLAogICAgICAibG9naW4iOiAidGFsZXhhbmRlciIsCiAgICAgICJsb2dpbl9uYW1lIjogIiIsCiAgICAgICJmdWxsX25hbWUiOiAiIiwKICAgICAgImVtYWlsIjogImdpdGVhQGxvY2FsLmRvbWFpbiIsCiAgICAgICJhdmF0YXJfdXJsIjogImh0dHBzOi8vY29kZS5maXp6LmJ1enovYXZhdGFycy85ZDQwMmE4OWI1YTA3ODZmODNjMWI4YzU0ODZmYzdmZjNkMDgzYTU0ZmUyMGU1NWMwYTc3NmExOTMyYzMwMjg5IiwKICAgICAgImxhbmd1YWdlIjogIiIsCiAgICAgICJpc19hZG1pbiI6IGZhbHNlLAogICAgICAibGFzdF9sb2dpbiI6ICIwMDAxLTAxLTAxVDAwOjAwOjAwWiIsCiAgICAgICJjcmVhdGVkIjogIjIwMjMtMDctMDVUMjI6MDM6MjhaIiwKICAgICAgInJlc3RyaWN0ZWQiOiBmYWxzZSwKICAgICAgImFjdGl2ZSI6IGZhbHNlLAogICAgICAicHJvaGliaXRfbG9naW4iOiBmYWxzZSwKICAgICAgImxvY2F0aW9uIjogIiIsCiAgICAgICJ3ZWJzaXRlIjogIiIsCiAgICAgICJkZXNjcmlwdGlvbiI6ICIiLAogICAgICAidmlzaWJpbGl0eSI6ICJwdWJsaWMiLAogICAgICAiZm9sbG93ZXJzX2NvdW50IjogMCwKICAgICAgImZvbGxvd2luZ19jb3VudCI6IDAsCiAgICAgICJzdGFycmVkX3JlcG9zX2NvdW50IjogMCwKICAgICAgInVzZXJuYW1lIjogInRhbGV4YW5kZXIiCiAgICB9LAogICAgIm5hbWUiOiAid2ViaG9va19icmlkZ2UiLAogICAgImZ1bGxfbmFtZSI6ICJ0YWxleGFuZGVyL3dlYmhvb2tfYnJpZGdlIiwKICAgICJkZXNjcmlwdGlvbiI6ICJBIHNlcnZlciB0aGF0IHJlY2VpdmVzIHdlYmhvb2tzIGZyb20gZ2l0ZWEgYW5kIGZpcmVzIG9mZiBUZWt0b24gam9icyBpbiByZXNwb25zZS4iLAogICAgImVtcHR5IjogZmFsc2UsCiAgICAicHJpdmF0ZSI6IGZhbHNlLAogICAgImZvcmsiOiBmYWxzZSwKICAgICJ0ZW1wbGF0ZSI6IGZhbHNlLAogICAgInBhcmVudCI6IG51bGwsCiAgICAibWlycm9yIjogZmFsc2UsCiAgICAic2l6ZSI6IDEyNywKICAgICJsYW5ndWFnZSI6ICIiLAogICAgImxhbmd1YWdlc191cmwiOiAiaHR0cHM6Ly9jb2RlLmZpenouYnV6ei9hcGkvdjEvcmVwb3MvdGFsZXhhbmRlci93ZWJob29rX2JyaWRnZS9sYW5ndWFnZXMiLAogICAgImh0bWxfdXJsIjogImh0dHBzOi8vY29kZS5maXp6LmJ1enovdGFsZXhhbmRlci93ZWJob29rX2JyaWRnZSIsCiAgICAidXJsIjogImh0dHBzOi8vY29kZS5maXp6LmJ1enovYXBpL3YxL3JlcG9zL3RhbGV4YW5kZXIvd2ViaG9va19icmlkZ2UiLAogICAgImxpbmsiOiAiIiwKICAgICJzc2hfdXJsIjogImdpdEBjb2RlLmZpenouYnV6ejp0YWxleGFuZGVyL3dlYmhvb2tfYnJpZGdlLmdpdCIsCiAgICAiY2xvbmVfdXJsIjogImh0dHBzOi8vY29kZS5maXp6LmJ1enovdGFsZXhhbmR
|
2024-07-14 20:13:06 +00:00
|
|
|
EOF
|
2024-07-16 01:02:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
sha256signature=$(echo "$payload" | openssl sha256 -hmac "$WEBHOOK_BRIDGE_HMAC_SECRET" | awk '{print $2}')
|
|
|
|
sha1signature=$(echo "$payload" | openssl sha1 -hmac "$WEBHOOK_BRIDGE_HMAC_SECRET" | awk '{print $2}')
|
2024-07-14 20:13:06 +00:00
|
|
|
|
2024-07-16 01:02:30 +00:00
|
|
|
curl -v \
|
|
|
|
--http2-prior-knowledge \
|
|
|
|
-X POST \
|
|
|
|
-H 'Content-Type: application/json' \
|
|
|
|
-H 'X-GitHub-Delivery: 90c4c994-dd31-4a21-8902-92aa76a10e53' \
|
|
|
|
-H 'X-GitHub-Event: push' \
|
|
|
|
-H 'X-GitHub-Event-Type: push' \
|
|
|
|
-H 'X-Gitea-Delivery: 90c4c994-dd31-4a21-8902-92aa76a10e53' \
|
|
|
|
-H 'X-Gitea-Event: push' \
|
|
|
|
-H 'X-Gitea-Event-Type: push' \
|
|
|
|
-H "X-Gitea-Signature: $sha256signature" \
|
|
|
|
-H 'X-Gogs-Delivery: 90c4c994-dd31-4a21-8902-92aa76a10e53' \
|
|
|
|
-H 'X-Gogs-Event: push' \
|
|
|
|
-H 'X-Gogs-Event-Type: push' \
|
|
|
|
-H "X-Gogs-Signature: $sha256signature" \
|
|
|
|
-H "X-Hub-Signature: sha1=$sha1signature" \
|
|
|
|
-H "X-Hub-Signature-256: sha256=$sha256signature" \
|
|
|
|
-d @- \
|
|
|
|
'http://127.0.0.1:9988/hook' <<<"$payload"
|
2024-07-14 20:13:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "${@}"
|