Skip to content

Adding reviewers

Adding reviewers #332

Workflow file for this run

name: ci
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
permissions:
contents: read # Allows read access to the code in the repository
on:
push:
schedule:
- cron: '0 0 * * *' # Runs every midnight (00:00 UTC)
workflow_dispatch: # Allows manual triggering
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
- name: Compile
run: yarn && yarn build
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
- name: Compile & Test
run: yarn && yarn test
run-examples:
name: Run examples (to look for regressions)
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 21
- name: Build
run: yarn && yarn build
- name: Test examples
run: |
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Running hello world"
node examples/hello-world.mjs
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Running smoke test"
node examples/smoke-test.mjs
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Running trade search"
node examples/trade-search.mjs
publish:
needs: [compile, test, run-examples]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Publish to npm
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.SDK_NPM_TOKEN }}
notify-slack-ci:
name: Notify Slack - CI Jobs Completed
needs: [compile, test, run-examples]
runs-on: ubuntu-latest
if: success()
steps:
- name: Check for PR on the branch and get reviewers
id: pr_check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch open PRs for the branch using GitHub API
PR_NUMBER=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}&state=open" \
| jq '.[0].number // empty')
if [ -n "$PR_NUMBER" ]; then
echo "This branch has an open pull request: #$PR_NUMBER"
echo "::set-output name=pr_number::$PR_NUMBER"
# Fetch reviewers for the PR
REVIEWERS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/requested_reviewers" \
| jq -r '.users[].login' | sed 's/^/@/g' | paste -sd ", ")
echo "::set-output name=reviewers::$REVIEWERS"
else
echo "No open pull requests for this branch."
echo "::set-output name=pr_number::"
echo "::set-output name=reviewers::"
fi
- name: Send Slack Notification
env:
WEBHOOK_URL: ${{ secrets.GH_ACTION_WEBHOOK_URL }}
GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REPOSITORY: ${{ github.repository }}
run: |
# Branch, PR, and reviewers info
BRANCH=${{ github.ref_name }}
PR_NUMBER="${{ steps.pr_check.outputs.pr_number }}"
REVIEWERS="${{ steps.pr_check.outputs.reviewers }}"
# Construct PR link if PR_NUMBER is set
if [ -n "$PR_NUMBER" ]; then
PULL_REQUEST_INFO="Pull-Request: <https://github.com/${REPOSITORY}/pull/${PR_NUMBER}|#${PR_NUMBER}>"
else
PULL_REQUEST_INFO=""
fi
# Include reviewers if available
if [ -n "$REVIEWERS" ]; then
REVIEWERS_INFO="Reviewers: $REVIEWERS"
else
REVIEWERS_INFO=""
fi
# Slack message format
MESSAGE="CI Build for Branch : *${BRANCH}* (${REPOSITORY})\nCommit Author : @${{ github.actor }}\n*Click <${GITHUB_RUN_URL}|here> for the job URL*"
# Append pull request info and reviewers if they exist
if [ -n "$PULL_REQUEST_INFO" ]; then
MESSAGE="$MESSAGE\n${PULL_REQUEST_INFO}"
fi
if [ -n "$REVIEWERS_INFO" ]; then
MESSAGE="$MESSAGE\n${REVIEWERS_INFO}"
fi
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$MESSAGE\"}" $WEBHOOK_URL
notify-slack-publish:
name: Notify Slack - Publish Job Completed
needs: [publish]
runs-on: ubuntu-latest
if: success()
steps:
- name: Send Slack Notification
env:
WEBHOOK_URL: ${{ secrets.GH_ACTION_WEBHOOK_URL }}
GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
BRANCH=${{ github.ref_name }}
MESSAGE="Publish job for branch *${BRANCH}* completed successfully. Package is now available. See details here: $GITHUB_RUN_URL"
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$MESSAGE\"}" $WEBHOOK_URL