-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (51 loc) · 1.54 KB
/
npm-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
on:
pull_request:
types: [closed, opened]
jobs:
dry-run:
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- name: Check formatting
run: |
set -eo pipefail
files_to_format=$(npm run format:check --silent || true)
if [ -n "$files_to_format" ]; then
echo "The following files are not formatted correctly:"
echo "$files_to_format"
{
echo "formatted_files<<EOF"
echo "$files_to_format"
echo "EOF"
echo "formatting_needed=true"
} >> $GITHUB_OUTPUT
exit 1
else
echo "All files are formatted correctly."
echo "formatting_needed=false" >> $GITHUB_OUTPUT
fi
- run: npm test
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
dry-run: true
publish:
needs: dry-run
if: github.event.pull_request.merged == true && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm test
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}