Skip to content

Instantly share code, notes, and snippets.

@g3rhard
Created August 2, 2021 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g3rhard/1931a4ff5089ce235415c09014c00cce to your computer and use it in GitHub Desktop.
Save g3rhard/1931a4ff5089ce235415c09014c00cce to your computer and use it in GitHub Desktop.
Example webhook trigger for Jenkins
name: Component Triggering
on:
issue_comment:
types:
- created
jobs:
trigger-webhook:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
steps:
- uses: actions/github-script@v3
id: get-pr
with:
script: |
const request = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
}
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
try {
const result = await github.pulls.get(request)
return result.data
} catch (err) {
core.setFailed(`Request failed with error ${err}`)
}
- uses: joelwmale/webhook-action@master
with:
url: 'https://gpuci.gpuopenanalytics.com/generic-webhook-trigger/invoke'
headers: '{"token": "${{ secrets.WEBHOOK_TOKEN }}"}'
body: |
{
"pr_id": "${{ github.event.issue.number }}",
"commit_hash": "origin/pr/${{ github.event.issue.number }}/merge",
"report_hash": "${{ fromJSON(steps.get-pr.outputs.result).head.sha }}",
"pr_author": "${{ github.event.issue.user.login }}",
"source_branch": "${{ fromJSON(steps.get-pr.outputs.result).head.ref }}",
"target_branch": "${{ fromJSON(steps.get-pr.outputs.result).base.ref }}",
"flash_id": "${{ github.event.issue.number }}",
"repository": "${{ github.event.repository.full_name }}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment