39 lines
8.7 KiB
Bash
Executable File
39 lines
8.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
function main() {
|
|
local payload sha256signature sha1signature
|
|
payload=$(base64 -d <<EOF
|
|
ewogICJyZWYiOiAicmVmcy9oZWFkcy9tYWluIiwKICAiYmVmb3JlIjogIjQ1NTViYjY4OTRhNTlkOGZiYTg4OTk3YjUxNzYxZjBmZWIzNDQyY2EiLAogICJhZnRlciI6ICJiOTFmNjM4ODRhZmQ2Y2EwMGMwNzZhMGY5MGNlNWIzNzEzYWZjYzkyIiwKICAiY29tcGFyZV91cmwiOiAiaHR0cHM6Ly9jb2RlLmZpenouYnV6ei90YWxleGFuZGVyL3dlYmhvb2tfYnJpZGdlL2NvbXBhcmUvNDU1NWJiNjg5NGE1OWQ4ZmJhODg5OTdiNTE3NjFmMGZlYjM0NDJjYS4uLmI5MWY2Mzg4NGFmZDZjYTAwYzA3NmEwZjkwY2U1YjM3MTNhZmNjOTIiLAogICJjb21taXRzIjogWwogICAgewogICAgICAiaWQiOiAiYjkxZjYzODg0YWZkNmNhMDBjMDc2YTBmOTBjZTViMzcxM2FmY2M5MiIsCiAgICAgICJtZXNzYWdlIjogIndpcFxuIiwKICAgICAgInVybCI6ICJodHRwczovL2NvZGUuZml6ei5idXp6L3RhbGV4YW5kZXIvd2ViaG9va19icmlkZ2UvY29tbWl0L2I5MWY2Mzg4NGFmZDZjYTAwYzA3NmEwZjkwY2U1YjM3MTNhZmNjOTIiLAogICAgICAiYXV0aG9yIjogewogICAgICAgICJuYW1lIjogIlRvbSBBbGV4YW5kZXIiLAogICAgICAgICJlbWFpbCI6ICJ0b21AZml6ei5idXp6IiwKICAgICAgICAidXNlcm5hbWUiOiAiIgogICAgICB9LAogICAgICAiY29tbWl0dGVyIjogewogICAgICAgICJuYW1lIjogIlRvbSBBbGV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ZW1vdmVkIjogW10sCiAgICAibW9kaWZpZWQiOiBbCiAgICAgICJDYXJnby5sb2NrIiwKICAgICAgIkNhcmdvLnRvbWwiLAogICAgICAic3JjL3dlYmhvb2sucnMiCiAgICBdCiAgfSwKICAicmVwb3NpdG9yeSI6IHsKICAgICJpZCI6IDIxLAogICAgIm93bmVyIjogewogICAgICAiaWQiOiAxLAogICAgICAibG9naW4iOiAidGFsZXhhbmRlciIsCiAgICAgICJsb2dpbl9uYW1lIjogIiIsCiAgICAgICJmdWxsX25hbWUiOiAiIiwKICAgICAgImVtYWlsIjogImdpdGVhQGxvY2FsLmRvbWFpbiIsCiAgICAgICJhdmF0YXJfdXJsIjogImh0dHBzOi8vY29kZS5maXp6LmJ1enovYXZhdGFycy85ZDQwMmE4OWI1YTA3ODZmODNjMWI4YzU0ODZmYzdmZjNkMDgzYTU0ZmUyMGU1NWMwYTc3NmExOTMyYzMwMjg5IiwKICAgICAgImxhbmd1YWdlIjogIiIsCiAgICAgICJpc19hZG1pbiI6IGZhbHNlLAogICAgICAibGFzdF9sb2dpbiI6ICIwMDAxLTAxLTAxVDAwOjAwOjAwWiIsCiAgICAgICJjcmVhdGVkIjogIjIwMjMtMDctMDVUMjI6MDM6MjhaIiwKICAgICAgInJlc3RyaWN0ZWQiOiBmYWxzZSwKICAgICAgImFjdGl2ZSI6IGZhbHNlLAogICAgICAicHJvaGliaXRfbG9naW4iOiBmYWxzZSwKICAgICAgImxvY2F0aW9uIjogIiIsCiAgICAgICJ3ZWJzaXRlIjogIiIsCiAgICAgICJkZXNjcmlwdGlvbiI6ICIiLAogICAgICAidmlzaWJpbGl0eSI6ICJwdWJsaWMiLAogICAgICAiZm9sbG93ZXJzX2NvdW50IjogMCwKICAgICAgImZvbGxvd2luZ19jb3VudCI6IDAsCiAgICAgICJzdGFycmVkX3JlcG9zX2NvdW50IjogMCwKICAgICAgInVzZXJuYW1lIjogInRhbGV4YW5kZXIiCiAgICB9LAogICAgIm5hbWUiOiAid2ViaG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F
|
|
)
|
|
|
|
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}')
|
|
|
|
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"
|
|
}
|
|
|
|
main "${@}"
|