wofkflow bug fix #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy on sdk update | |
on: | |
push: | |
branches: | |
- master | |
repository_dispatch: | |
types: [sdk-update] | |
jobs: | |
update-sdk: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Determine sdk version | |
id: determine-sdk-version | |
run: | | |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then | |
echo "::set-output name=version::${{ github.event.client_payload.version }}" | |
else | |
# Get the current version of sdk used in package.json | |
CURRENT_VERSION=$(node -e "console.log(require('./ts/sdk/package.json').dependencies['@drift-labs/sdk'])") | |
echo "::set-output name=version::$CURRENT_VERSION" | |
fi | |
- name: Install dependencies | |
run: yarn | |
working-directory: ts/sdk | |
- name: Add specific version of sdk | |
run: yarn add @drift-labs/sdk@${{ steps.determine-sdk-version.outputs.version }} | |
working-directory: ts/sdk | |
- run: yarn build | |
working-directory: ts/sdk | |
- name: Update package version | |
run: npm version patch | |
working-directory: ts/sdk | |
- name: Git commit | |
id: publish-jit-sdk | |
run: | | |
VERSION=$(node -e "console.log(require('./package.json').version);") | |
git config user.name "GitHub Actions" | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git add -A | |
git commit --allow-empty -m "sdk: release v$VERSION" | |
git push origin HEAD | |
echo "::set-output name=jit-version::$VERSION" | |
working-directory: ts/sdk | |
- name: Publish to npm | |
run: npm publish --access=public | |
working-directory: ts/sdk | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Emit dispatch event | |
run: | | |
curl -X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: token ${{ secrets.GH_PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/repos/drift-labs/keeper-bots-v2/dispatches" \ | |
-d "{\"event_type\": \"jit-sdk-update\", \"client_payload\": { | |
\"sdk-version\": \"${{ steps.determine-sdk-version.outputs.version }}\", | |
\"jit-version\": \"${{ steps.publish-jit-sdk.outputs.version }}\" | |
}}" | |
env: | |
GH_PAT: ${{ secrets.GH_PAT }} | |