Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

Commit f01be8c

Browse files
committed
chore(gha): add npm.yml GitHub workflow
1 parent 3e374b5 commit f01be8c

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

.github/workflows/npm.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# DO NOT EDIT: BEGIN
2+
# This snippet has been inserted automatically by mobsuccessbot, do not edit!
3+
# If changes are needed, update the action npm in
4+
# https://github.com/mobsuccess-devops/github-mobsuccess-policy
5+
on:
6+
merge_group:
7+
types:
8+
- checks_requested
9+
push:
10+
branches: [master, preprod, prod]
11+
pull_request:
12+
types: [opened, synchronize, reopened]
13+
name: NPM
14+
jobs:
15+
packagejsonlint:
16+
name: PackageJsonLint
17+
runs-on: ubuntu-20.04
18+
timeout-minutes: 1
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: mobsuccess-devops/github-actions-packagejsonlint@master
22+
sortpackagejson:
23+
name: Sort Package Json
24+
runs-on: ubuntu-20.04
25+
timeout-minutes: 7
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 20.12.0
31+
- name: Cache Node Modules
32+
id: cache
33+
uses: actions/cache@v4
34+
env:
35+
cache-name: cache-node-modules
36+
with:
37+
path: ./node_modules
38+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0
39+
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc
40+
name: Configure Credentials For GitHub Packages
41+
- run: npm ci
42+
if: steps.cache.outputs.cache-hit != 'true'
43+
working-directory: .
44+
- run: |
45+
echo "💡 👉 Check not passing? see the doc at https://www.notion.so/mobsuccess/sort-package-json-de5cf4648e8545dbb5a2a5a910380535"
46+
npx --yes [email protected] --check
47+
working-directory: .
48+
prettier:
49+
name: Prettier
50+
runs-on: ubuntu-20.04
51+
timeout-minutes: 7
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: actions/setup-node@v4
55+
with:
56+
node-version: 20.12.0
57+
- name: Cache Node Modules
58+
id: cache
59+
uses: actions/cache@v4
60+
env:
61+
cache-name: cache-node-modules
62+
with:
63+
path: ./node_modules
64+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0
65+
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc
66+
name: Configure Credentials For GitHub Packages
67+
- run: npm ci
68+
if: steps.cache.outputs.cache-hit != 'true'
69+
working-directory: .
70+
- run: npm run prettier
71+
working-directory: .
72+
eslint:
73+
name: Eslint
74+
runs-on: ubuntu-20.04
75+
timeout-minutes: 7
76+
steps:
77+
- uses: actions/checkout@v4
78+
- uses: actions/setup-node@v4
79+
with:
80+
node-version: 20.12.0
81+
- name: Cache Node Modules
82+
id: cache
83+
uses: actions/cache@v4
84+
env:
85+
cache-name: cache-node-modules
86+
with:
87+
path: ./node_modules
88+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0
89+
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc
90+
name: Configure Credentials For GitHub Packages
91+
- run: npm ci
92+
if: steps.cache.outputs.cache-hit != 'true'
93+
working-directory: .
94+
- run: npm run eslint
95+
working-directory: .
96+
test:
97+
name: Test
98+
runs-on: ubuntu-20.04
99+
timeout-minutes: 7
100+
steps:
101+
- uses: actions/checkout@v4
102+
- uses: actions/setup-node@v4
103+
with:
104+
node-version: 20.12.0
105+
- name: Cache Node Modules
106+
id: cache
107+
uses: actions/cache@v4
108+
env:
109+
cache-name: cache-node-modules
110+
with:
111+
path: ./node_modules
112+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0
113+
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc
114+
name: Configure Credentials For GitHub Packages
115+
- run: npm ci
116+
if: steps.cache.outputs.cache-hit != 'true'
117+
working-directory: .
118+
- run: npm run test
119+
working-directory: .
120+
# DO NOT EDIT: END

0 commit comments

Comments
 (0)