-
Notifications
You must be signed in to change notification settings - Fork 2
56 lines (47 loc) · 1.86 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# --------------------------------------------------- #
# ------------------------ 3 ------------------------ #
# --------------------------------------------------- #
name: Publish to NPM
run-name: ${{ github.actor }} publish to npm 🚀
on:
# we are using workflow_run to trigger the workflow
# because we want to run this workflow only when the Approve PR and delete branch workflow is completed
# GitHub prevents workflows from running on events that were caused by other workflows to prevent unlimited recursion
# so we do not use the release event
# issue: https://github.com/orgs/community/discussions/25281
# see: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
workflow_run:
# the workflow we want to trigger this workflow (see .github/workflows/add-badges.yml)
# workflows: [Approve PR and delete branch]
workflows: [Add Badges]
types: [completed]
# run on release creation
# release:
# types: [created]
jobs:
publish:
runs-on: ubuntu-latest
# if: github.actor == 'dependabot[bot]'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
# need this for using yarn v4
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
# npm publish
- name: Publish package on NPM 📦
# if using yarn v4
run: yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: echo "Published to NPM 🚀- https://www.npmjs.com/package/${{ github.event.repository.name }}"