Skip to content

Commit 07985c1

Browse files
committed
feat: deploy on release
1 parent a49fdba commit 07985c1

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

.github/workflows/deploy.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
on:
2+
release:
3+
types: [prereleased]
4+
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v3
11+
with:
12+
node-version: "20"
13+
- run: npm ci
14+
- run: npm run lint
15+
- run: npm run test
16+
- run: npm run generate
17+
- name: Deploy to netlify branch
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
run: |
21+
git fetch
22+
git checkout netlify
23+
rm -rf ./*
24+
rm -rf .nuxt
25+
mv .output/public/* .
26+
rm -rf .output
27+
git add .
28+
git config --global user.email "[email protected]"
29+
git config --global user.name "publish action"
30+
git commit -m "deploy: $GITHUB_REF_NAME"
31+
git push origin netlify
32+
- name: Set release to latest
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
gh release edit ${GITHUB_REF_NAME} --prerelease=false --latest
37+

package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
"generate": "nuxt generate",
1111
"preview": "nuxt preview",
1212
"postinstall": "nuxt prepare",
13-
"start": "nuxt start",
14-
"deploy": "rm -rf .output; npm run generate; npm run deploy:2",
15-
"deploy:2": "cd .output/public; git init --initial-branch=main; git remote add origin [email protected]:Chalks/jdw.me.git; npm run deploy:3",
16-
"deploy:3": "cd .output/public; git add .; git commit -m 'Initial commit'; npm run deploy:4",
17-
"deploy:4": "cd .output/public; git push --force origin main:netlify"
13+
"start": "nuxt start"
1814
},
1915
"repository": {
2016
"type": "git",

0 commit comments

Comments
 (0)