Skip to content

Commit

Permalink
ci: deploy to npm action
Browse files Browse the repository at this point in the history
  • Loading branch information
bardisg authored Jan 6, 2023
2 parents 23e4079 + ce0f8d0 commit 37627fc
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 38 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/actions.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/deploy-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Deploy to NPM

on:
workflow_dispatch:
pull_request:
branches:
- master
types:
- closed

permissions:
id-token: write # allows the JWT to be requested from GitHub's OIDC provider
contents: read # This is required for actions/checkout

jobs:
deploy-tag:
name: Deploy to NPM
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/master') || github.event.pull_request.merged == true
steps:
- name: Checkout source branch
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Build files
env:
HUSKY: 0
run: |
npm ci
npm run build
- name: Publish package to NPM
env:
HUSKY: 0
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
cd lib
npm publish
- name: Get new version number
run: |
current_version=$(jq -r .version package.json)
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Send message to Slack channel
id: slack
uses: slackapi/slack-github-action@v1.23.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
PROJECT_NAME: 'Node SDK'
NPM_PACKAGE_URL: 'https://www.npmjs.com/package/@rudderstack/rudder-sdk-node'
with:
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New release: ${{ env.PROJECT_NAME }}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Release: <${{ env.NPM_PACKAGE_URL }}|${{ env.CURRENT_VERSION_VALUE }}>*\n${{ env.DATE }}"
}
}
]
}

0 comments on commit 37627fc

Please sign in to comment.