Skip to content

Commit ccd36d8

Browse files
committed
feat: try to auto compile dist/index.js
1 parent 8022558 commit ccd36d8

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

.github/workflows/AutoCompile.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# `dist/index.js` is a special file in Actions.
2+
# When you reference an action with `uses:` in a workflow,
3+
# `index.js` is the code that will run.
4+
# For our project, we generate this file through a build process from other source files.
5+
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
6+
name: Auto Compile dist/index.js
7+
8+
on:
9+
push:
10+
branches:
11+
- mod
12+
paths-ignore:
13+
- '**.md'
14+
workflow_dispatch:
15+
16+
jobs:
17+
auto_compile:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version-file: 'package.json'
28+
29+
- name: Install dependencies
30+
run: npm ci --ignore-scripts
31+
32+
- name: Rebuild the dist/ directory
33+
run: |
34+
npm run build
35+
npm run package
36+
37+
- name: correct vercel/ncc crlf output
38+
run: |
39+
# See https://github.com/vercel/ncc/issues/638
40+
sed -i 's/\x0D$//' ./dist/*
41+
42+
- name: Upload dist/index.js to GitHub Repository
43+
run: |
44+
git clone https://github-action:${{ secrets.GITHUB_TOKEN }}@github.com/MZWNET/cuda-toolkit.git -b mod cache
45+
rm -rf cache/dist/index.js
46+
cp dist/index.js cache/dist/index.js
47+
cd cache
48+
if ! git diff --quiet HEAD -- dist/index.js; then
49+
echo "dist/index.js has changes."
50+
git config --local user.email "actions@github.com"
51+
git config --local user.name "GitHub Actions Bot"
52+
git status
53+
git add dist/index.js
54+
git commit -m "feat: update dist/index.js"
55+
git push origin mod
56+
else
57+
echo "No changes in dist/index.js."
58+
fi

0 commit comments

Comments
 (0)