Skip to content

Commit 3919997

Browse files
committed
ci: adding Github Actions to run tests/build/linters using NX
1 parent b0f58be commit 3919997

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

.github/workflows/main.yml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,74 @@ on:
22
pull_request:
33
branches:
44
- master
5+
push:
6+
branches:
7+
- master
58

69
jobs:
710
github-action-show-version:
11+
if: github.event_name == 'pull_request'
812
runs-on: ubuntu-latest
913
name: Next version is
1014
steps:
1115
- name: Publish a version comment
1216
uses: rvsia/[email protected]
1317
id: comment
1418
with:
15-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
20+
21+
# Job that runs on PR (before merge)
22+
pr-checks:
23+
if: github.event_name == 'pull_request'
24+
runs-on: ubuntu-latest
25+
name: PR Checks
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
cache: 'yarn'
35+
36+
- name: Install dependencies
37+
run: yarn install --frozen-lockfile
38+
39+
- name: Derive appropriate SHAs for base and head for nx affected commands
40+
uses: nrwl/nx-set-shas@v4
41+
42+
- name: Run build on affected projects
43+
run: npx nx affected --target=build --parallel=3
44+
continue-on-error: false
45+
46+
- name: Run lint on affected projects
47+
run: npx nx affected --target=lint --parallel=3
48+
continue-on-error: false
49+
50+
- name: Run typecheck on affected projects
51+
run: npx nx affected --target=typecheck --parallel=3
52+
continue-on-error: false
53+
54+
- name: Run tests on affected projects
55+
run: npx nx affected --target=test --parallel=3 --coverage
56+
continue-on-error: false
57+
58+
- name: Run Nx release dry-run
59+
run: npx nx release --dry-run --verbose
60+
61+
# Job that runs after merge (on push to master)
62+
post-merge:
63+
if: github.event_name == 'push'
64+
runs-on: ubuntu-latest
65+
name: Post-merge Actions
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
- name: 🚀 Run Nx Release
70+
run: |
71+
npx nx release --skip-publish --verbose
72+
npx nx release publish --skip-existing --verbose
73+
env:
74+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)