chore: [PLM-6648] Add npm publish workflow #61
This file contains hidden or 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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | |
name: Publish Package | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
npm_publish: | |
if: "! contains(toJSON(github.event.commits.*.message), '[Version Bump]')" | |
name: NPM Publish | |
runs-on: ubuntu-latest | |
# runs-on: arc-scale-set | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.HOUZZ_CI_TOKEN }} | |
ref: chore/plm-6648-add-npm-publish | |
# ref: master | |
- name: Setup GIT | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "houzz-ci" | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: https://npm.pkg.github.com/ | |
scope: houzz | |
- name: Bump up patch version and push to github | |
run: | | |
npm version patch -m "chore: [Version Bump] %s" | |
git push "https://github.com/$GITHUB_REPOSITORY" chore/plm-6648-add-npm-publish --no-verify | |
# git push "https://github.com/$GITHUB_REPOSITORY" master --no-verify | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.HOUZZ_CI_TOKEN }} | |
- name: Publish package to github registry | |
run: | | |
npm publish --tag "latest" ./ > publish_message.txt | |
echo "##[set-output name=message;]$(cat publish_message.txt)" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.HOUZZ_CI_TOKEN }} | |
# - name: Send slack notification | |
# if: always() | |
# uses: ./node_modules/@houzz/gha-slack-notifications | |
# with: | |
# slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_FOR_PUBLISH }} | |
# slack_channel: 'jukwaa-deploy' | |
# job_title: 'Master Branch Package: Status of npm publish' | |
# run_id: ${{ github.run_id }} | |
# custom_message: '${{ steps.publish_package.outputs.message }}' | |
# job_status: '${{ job.status }}' |