Skip to content

Commit 9793101

Browse files
authored
Merge pull request #2 from AutomationDojo/improvements
feat: add improvements for ci and packaging
2 parents 85eb229 + b09cfc8 commit 9793101

5 files changed

Lines changed: 112 additions & 3 deletions

File tree

.github/workflows/check-dist.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Check dist/
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
paths-ignore:
11+
- '**.md'
12+
workflow_dispatch:
13+
14+
jobs:
15+
check-dist:
16+
name: Check dist/
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: read
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version-file: .node-version
30+
cache: npm
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build dist/
36+
run: npm run build
37+
38+
- name: Compare expected and actual dist/ directories
39+
run: |
40+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
41+
echo "Detected uncommitted changes after build. See status below:"
42+
git diff --ignore-space-at-eol --text dist/
43+
exit 1
44+
fi
45+
id: diff
46+
47+
- name: Upload artifact
48+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: dist
52+
path: dist/
53+
54+
- name: Fail if dist/ is out of sync
55+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
56+
run: |
57+
echo "::error::The dist/ directory is out of sync with the source code. Run 'npm run build' and commit the changes."
58+
exit 1

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: write
13+
issues: write
14+
pull-requests: write
15+
16+
jobs:
17+
test-action:
18+
name: GitHub Actions Test
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version-file: .node-version
29+
cache: npm
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Run tests
35+
run: npm test
36+
37+
- name: Test Local Action
38+
uses: ./
39+
with:
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
small-threshold: 100
42+
medium-threshold: 300
43+
large-threshold: 600

.github/workflows/release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ jobs:
2424
- name: Setup Node.js
2525
uses: actions/setup-node@v4
2626
with:
27-
node-version: '20'
27+
node-version-file: .node-version
28+
cache: npm
2829

2930
- name: Install dependencies
3031
run: npm ci
3132

33+
- name: Build dist/
34+
run: npm run build
35+
3236
- name: Release
3337
env:
3438
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
"description": "GitHub Action to automatically label PRs based on size",
55
"main": "index.js",
66
"scripts": {
7-
"build": "ncc build index.js -o dist",
8-
"test": "echo \"Error: no test specified\" && exit 1",
7+
"bundle": "npm run build",
8+
"build": "ncc build index.js -o dist --license licenses.txt",
9+
"package": "ncc build index.js -o dist --license licenses.txt",
10+
"all": "npm run build",
11+
"test": "echo \"No tests yet\"",
912
"semantic-release": "semantic-release"
1013
},
1114
"repository": {

0 commit comments

Comments
 (0)