GitHub Webhook
Last updated
Was this helpful?
Last updated
Was this helpful?
github์ ํธ์๊ฐ ๋๋ฉด webhook์ ์ฌ์ฉํด์ ํน์ ์๋ฒ์ ํต๋ณดํ๋ค.
Settings > webHooks >> Add Webhook
let me select individual events
๋ฅผ ์ ํํ๋ฉด ์ต์
์ด ๋์ค๋๋ฐ ์ ํํ๋ฉด๋๋ค.
๋๋ ๊ธฐ๋ณธ์ ์ผ๋ก just the push event
๋ง ์ ํํ๋ค.
content type์ ๊ทธ๋ฆผ๊ณผ ๋ค๋ฅด๊ฒ application/json
์ผ๋ก ์ ํํ๋ค.
์ด์ ํธ์๊ฐ ๋ค์ด์ค๋ฉด ์นํ ์ด ํธ์ถ๋๋ค.
ํ์ด๋ก๋๋ 25MB๋ก ์ ํ๋ฉ๋๋ค. ์ด๋ฒคํธ๊ฐ ๋ ํฐ ํ์ด๋ก๋๋ฅผ ์์ฑํ๋ ๊ฒฝ์ฐ, GitHub๋ ํด๋น ์นํ ์ด๋ฒคํธ์ ๋ํ ํ์ด๋ก๋๋ฅผ ์ ๊ณตํ์ง ์์ต๋๋ค.
X-GitHub-Hook-ID: The unique identifier of the webhook.
X-GitHub-Event: The name of the event that triggered the delivery.
X-GitHub-Delivery: A globally unique identifier (GUID) to identify the delivery.
X-Hub-Signature: This header is sent if the webhook is configured with a secret. This is the HMAC hex digest of the request body, and is generated using the SHA-1 hash function and the secret as the HMAC key. X-Hub-Signature is provided for compatibility with existing integrations. We recommend that you use the more secure X-Hub-Signature-256 instead.
X-Hub-Signature-256: This header is sent if the webhook is configured with a secret. This is the HMAC hex digest of the request body, and is generated using the SHA-256 hash function and the secret as the HMAC key. For more information, see "Validating webhook deliveries."
User-Agent: This header will always have the prefix GitHub-Hookshot/.
X-GitHub-Hook-Installation-Target-Type: The type of resource where the webhook was created.
X-GitHub-Hook-Installation-Target-ID: The unique identifier of the resource where the webhook was created.
๊ฐ๋จํ webapi์๋ฒ๋ฅผ ๋ง๋ค๊ณ ๋๋น๋ฅผ ๋ง๋ค์ด์ ๋ฆฌํ์คํธ๋ฅผ ๋ฐ์๋ณด๋ฉด ๋ ๊ฑฐ๊ฐ๋ค.
git push
๋ฅผ ํด๋ณด์.
์ค์๋ฒ์์ ๋ฆฌํ์คํธ๊ฐ ๋ค์ด์จ๊ฒ์ ์์์๋ค.
payload๋ฅผ ํ์ธํ์ฌ ๋๋น์ ์ ์ฅํ๋ฉด ๋
์ฌ๊ธฐ์ ์คํ๋ ๊ฒฐ๊ณผ๋ฅผ ๋ณผ์ ์๊ณ ์ค์ payload๋ฅผ ํ์ธํ ์ ์๋ค.
์คํจํ๋ฉด ์๋ฆผ๋งํฌ๊ฐ ๋ณด์ธ๋ค.
์ฐธ๊ณ ๋ก webhook๋ฅผ ๋ฐ๋ก ์ฐ์ง ์๊ณ action์ ์จ์ webhook์ ๋ฐ์์ํฌ์ ์๋ค.
https://github.com/marketplace/actions/workflow-webhook-action
์ด๊ฑธ yaml์ ์ฌ์ฉํ๋ฉด ๋๋ค.