Skip to content

Commit a1d798c

Browse files
authored
Merge pull request #297 from humanmade/build-ci
Refresh CI job and introduce Release action/branch
2 parents c0a4d57 + 211db7f commit a1d798c

6 files changed

Lines changed: 159 additions & 92 deletions

File tree

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build to "release" branch
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref_name }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
release:
14+
name: "Update release branch"
15+
uses: humanmade/hm-github-actions/.github/workflows/build-and-release-node.yml@a9a243d6c42fbff4a967d7ce0a6b307bc77251b7 # v0.1.0
16+
with:
17+
# Default build action `npm run build` is sufficient.
18+
node_version: 20
19+
source_branch: main
20+
release_branch: release
21+
built_asset_paths: dist

.github/workflows/ci.yml

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ on:
1111
- opened
1212
- ready_for_review
1313
- synchronize
14+
# Only run on a given PR if relevant files have changed.
15+
paths:
16+
- '.eslintignore'
17+
- '.eslintrc.js'
18+
- '.npmrc'
19+
- '**.js'
20+
- '**.json'
21+
- '**.jsx'
22+
- 'babel.config.js'
23+
- 'webpack.config.js'
1424

1525
defaults:
1626
run:
@@ -22,62 +32,5 @@ concurrency:
2232

2333
jobs:
2434
node:
25-
name: Node
26-
runs-on: ubuntu-22.04
27-
28-
strategy:
29-
matrix:
30-
node-version: [ 16 ]
31-
32-
steps:
33-
- name: Checkout
34-
uses: actions/checkout@v3
35-
36-
- name: Paths filters
37-
uses: dorny/paths-filter@v2
38-
id: paths
39-
with:
40-
filters: |
41-
workflows: &workflows
42-
- '.github/actions/**/*.yml'
43-
- '.github/workflows/**/*.yml'
44-
npm: &npm
45-
- *workflows
46-
- 'package.json'
47-
- 'package-lock.json'
48-
javascript: &javascript
49-
- *workflows
50-
- '**/*.js'
51-
eslint:
52-
- *workflows
53-
- *javascript
54-
- *npm
55-
- '**/*.json'
56-
- '.eslintignore'
57-
- '.eslintrc'
58-
59-
- name: Setup
60-
if: ${{ toJSON( steps.paths.outputs.changes ) != '"[]"' }}
61-
uses: ./.github/actions/setup-node
62-
with:
63-
cache_version: ${{ secrets.GH_ACTIONS_CACHE_KEY }}
64-
65-
- name: Install dependencies
66-
if: ${{ toJSON( steps.paths.outputs.changes ) != '"[]"' && steps.cache-node-dependencies.outputs.cache-hit != 'true' }}
67-
run: npm ci --no-progress --no-fund --no-audit --loglevel error
68-
69-
- name: Lint code
70-
if: ${{ steps.paths.outputs.eslint == 'true' }}
71-
uses: wearerequired/lint-action@v2
72-
with:
73-
continue_on_error: false
74-
eslint: true
75-
eslint_extensions: js,json
76-
77-
- name: Run tests
78-
if: ${{ steps.paths.outputs.javascript == 'true' || steps.paths.outputs.npm == 'true' }}
79-
run: npm test
80-
81-
- name: Build application
82-
if: ${{ steps.paths.outputs.javascript == 'true' || steps.paths.outputs.npm == 'true' }}
83-
run: npm run build
35+
uses: ./.github/workflows/node.yml
36+
secrets: inherit

.github/workflows/node.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Node
2+
3+
on: workflow_call
4+
5+
jobs:
6+
node:
7+
name: Node
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
node-version: [ 20 ]
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
18+
- name: Paths filters
19+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
20+
id: paths
21+
with:
22+
filters: |
23+
workflows: &workflows
24+
- '.github/actions/**/*.yml'
25+
- '.github/workflows/**/*.yml'
26+
npm: &npm
27+
- *workflows
28+
- 'package.json'
29+
- 'package-lock.json'
30+
javascript: &javascript
31+
- *workflows
32+
- '**/*.js'
33+
eslint:
34+
- *workflows
35+
- *javascript
36+
- *npm
37+
- '**/*.json'
38+
- '.eslintignore'
39+
- '.eslintrc.js'
40+
41+
- name: Set up Node
42+
if: ${{ toJSON( steps.paths.outputs.changes ) != '"[]"' }}
43+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
44+
with:
45+
node-version: ${{ matrix.node-version }}
46+
cache: 'npm'
47+
48+
- name: Install dependencies
49+
if: ${{ toJSON( steps.paths.outputs.changes ) != '"[]"' && steps.cache-node-dependencies.outputs.cache-hit != 'true' }}
50+
run: npm ci --progress=false --audit=false --fund=false
51+
52+
- name: Lint code and save linting report JSON
53+
if: ${{ steps.paths.outputs.eslint == 'true' }}
54+
run: npm run lint -- --output-file eslint_report.json --format json
55+
# Continue to the next step even if this fails, so we can report on it.
56+
continue-on-error: true
57+
58+
- name: Annotate Code Linting Results
59+
uses: ataylorme/eslint-annotate-action@d57a1193d4c59cbfbf3f86c271f42612f9dbd9e9 # v3.0.0
60+
with:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
report-json: 'eslint_report.json'
63+
only-pr-files: true
64+
65+
- name: Run tests
66+
if: ${{ steps.paths.outputs.javascript == 'true' || steps.paths.outputs.npm == 'true' }}
67+
run: npm test
68+
69+
- name: Build application
70+
if: ${{ steps.paths.outputs.javascript == 'true' || steps.paths.outputs.npm == 'true' }}
71+
run: npm run build

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.18.0
1+
v20

package-lock.json

Lines changed: 53 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"eslint-config-react-app": "^7.0.1",
4040
"eslint-plugin-flowtype": "^8.0.3",
4141
"eslint-plugin-import": "^2.27.5",
42-
"eslint-plugin-jsdoc": "^39.3.23",
42+
"eslint-plugin-jsdoc": "^45.0.0",
4343
"eslint-plugin-jsonc": "^2.7.0",
4444
"eslint-plugin-jsx-a11y": "^6.7.1",
4545
"eslint-plugin-react": "^7.32.2",

0 commit comments

Comments
 (0)