Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Perrotte <mike@npmjs.com>2020-01-10 13:56:50 +0300
committerMichael Perrotte <mike@npmjs.com>2020-01-28 20:37:21 +0300
commit1ce034484ca9fd05d667111ca249d5d43ae64fcc (patch)
treec492e05cb9ea8644bbb2c7d798df5b53fa997c13
parent5967fa44b3908fde0fcf3379c1d81c53a82903d8 (diff)
feat: updated workflow for pull-ruquest benchmark dispatch requests
-rw-r--r--.github/workflows/benchmark.yml72
1 files changed, 46 insertions, 26 deletions
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index a49ed8495..0920f711c 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -16,33 +16,53 @@ jobs:
runs-on: ubuntu-latest
steps:
- # Checkout the npm/cli repo
- - uses: actions/checkout@v2
-
- # Installs the specific version of nodejs
- - name: Use nodejs 12.x
- uses: actions/setup-node@v1
- with:
- node-version: "12.x"
-
- # Trigger Webhook
- - name: Trigger Webhook
+ - name: Handle Incoming Pull-Request
env:
DISPATCH_REPO: "benchmarks"
DISPATCH_OWNER: "npm"
+ EVENT_NAME: ${{ github.event_name }}
+ EVENT_ACTION: ${{ github.event.action }}
+ REPO: ${{ github.event.repository.name }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ PR_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
+ PR_COMMITS_URL: ${{ github.event.pull_request.commits_url }}
+ PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
+ AUTH_TOKEN: ${{ secrets.NPM_DEPLOY_USER_PAT }}
run: |
- curl \
- -s \
- -X POST https://api.github.com/repos/${DISPATCH_OWNER}/${DISPATCH_REPO}/dispatches \
- -H "Accept: application/vnd.github.everest-preview+json" \
- -d \
- '
- {
- "event_type": "${{ github.event_name }}",
- "client_payload": {
- "pr_id": "${{ github.event.pull_request.number }}",
- "repo": "${{ github.event.repository.name }}",
- "owner": "${{ github.event.repository.owner.login }}",
- "commit_sha": "${{ github.event.after }}"
- }
- }'
+ # Dispatch Handler
+
+ dispatch_request () {
+ echo "Dispatching request..."
+ REF_SHA=$1
+ curl \
+ -s \
+ -X POST https://api.github.com/repos/${DISPATCH_OWNER}/${DISPATCH_REPO}/dispatches \
+ -H "Accept: application/vnd.github.everest-preview+json" \
+ -H "Authorization: token ${AUTH_TOKEN}" \
+ -d \
+ '
+ {
+ "event_type": "'"${EVENT_NAME}"'",
+ "client_payload": {
+ "pr_id": "'"${PR_NUMBER}"'",
+ "repo": "'"${REPO}"'",
+ "owner": "'"${PR_OWNER}"'",
+ "commit_sha": "'"${REF_SHA}"'"
+ }
+ }'
+ }
+
+ if [ "${AUTH_TOKEN}" != "" ]; then
+ if [ "${EVENT_ACTION}" == "opened" ]; then
+ # Fetch the head commit sha, since it doesn't exist in the body of this event
+ COMMIT_SHA=$(curl -s "${PR_COMMITS_URL}" | jq -r '.[0].sha')
+
+ # Dispatch request for benchmarks
+ dispatch_request "${COMMIT_SHA}"
+ else
+ # Dispatch request for benchmarks
+ dispatch_request "${PR_COMMIT_SHA}"
+ fi
+ else
+ echo "NO AUTH - FORK PULL REQUEST"
+ fi