Skip to content

Commit 1e34731

Browse files
authored
Add a new workflow to build the dist (#99)
Added workflow to build and push dist folder generation and commit to the pull request branch. Removed custom npm cache to use default caching from actions/node
1 parent 5ce493b commit 1e34731

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

.github/workflows/build-dist.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build dist
2+
3+
on:
4+
pull_request:
5+
types: [ labeled ]
6+
7+
jobs:
8+
build:
9+
if: ${{ github.event.label.name == 'build-dist' }}
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.pull_request.head.ref }}
17+
- name: Setup Node.js 20.x
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20.x
21+
cache: 'npm'
22+
- run: npm ci --legacy-peer-deps
23+
- run: npm run build
24+
- name: Commit changes if any in dist/
25+
run: |
26+
if [ -n "$(git status --porcelain dist/)" ]; then
27+
echo "Changes detected in dist/"
28+
git add dist/
29+
git config --global user.name "github-actions"
30+
git config --global user.email "github-actions@github.com"
31+
git commit -m "Generate dist"
32+
git push origin ${{ github.event.pull_request.head.ref }}
33+
else
34+
echo "No changes"
35+
fi

.github/workflows/workflow.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@ jobs:
2626
uses: actions/setup-node@v4
2727
with:
2828
node-version: 20.x
29-
- name: Determine npm cache directory
30-
id: npm-cache
31-
run: |
32-
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
33-
- name: Restore npm cache
34-
uses: actions/cache@v4
35-
with:
36-
path: ${{ steps.npm-cache.outputs.dir }}
37-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
38-
restore-keys: |
39-
${{ runner.os }}-node-
29+
cache: 'npm'
4030
- run: npm ci --legacy-peer-deps
4131
- name: Prettier Format Check
4232
run: npm run format-check

0 commit comments

Comments
 (0)