Compare commits
2 Commits
2feffe52cd
...
075c41b7c1
Author | SHA1 | Date | |
---|---|---|---|
075c41b7c1 | |||
2480d41e20 |
38
.gitea/workflows/deplopy-dev.yaml
Normal file
38
.gitea/workflows/deplopy-dev.yaml
Normal file
@ -0,0 +1,38 @@
|
||||
name: Build and deploy to dev server
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
npm_config_registry: ${{ vars.REGISTRY_URL }}
|
||||
|
||||
jobs:
|
||||
Deploy:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.20.3
|
||||
registry-url: ${{ vars.REGISTRY_URL }}
|
||||
cache: 'pnpm'
|
||||
- name: Install deps
|
||||
run: pnpm install
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
- name: Deploy to Server
|
||||
uses: easingthemes/ssh-deploy@v2.1.5
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
|
||||
ARGS: '-rltgoDzvO --delete'
|
||||
SOURCE: dist # 这是要复制到阿里云静态服务器的文件夹名称
|
||||
REMOTE_HOST: '192.168.0.19' # 你的阿里云公网地址
|
||||
REMOTE_USER: root # 阿里云登录后默认为 root 用户,并且所在文件夹为 root
|
||||
TARGET: /var/www/test/ # 打包后的 dist 文件夹将放在 /root/node-server
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# node modules
|
||||
node_modules/
|
||||
|
||||
# build files
|
||||
dist/
|
12
build.js
Normal file
12
build.js
Normal file
@ -0,0 +1,12 @@
|
||||
// 将当前时间写入dist/index.html
|
||||
console.log('start build');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const moment = require('moment');
|
||||
const buildTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
const indexPath = path.resolve(__dirname, 'index.html');
|
||||
const distIndexPath = path.resolve(__dirname, 'dist/index.html');
|
||||
const indexContent = fs.readFileSync(indexPath, 'utf-8');
|
||||
const newIndexContent = indexContent.replace(/<span id="build-time">.*<\/span>/, `<span id="build-time">${buildTime}</span>`);
|
||||
fs.writeFileSync(distIndexPath, newIndexContent, 'utf-8');
|
||||
console.log('build success');
|
0
dist/.gitkeep
vendored
Normal file
0
dist/.gitkeep
vendored
Normal file
12
index.html
Normal file
12
index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<span id="build-time">Unk Time</span>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
16
package.json
Normal file
16
package.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "ci-publish-test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "node build.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"moment": "^2.30.1"
|
||||
}
|
||||
}
|
22
pnpm-lock.yaml
Normal file
22
pnpm-lock.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
moment:
|
||||
specifier: ^2.30.1
|
||||
version: 2.30.1
|
||||
|
||||
packages:
|
||||
|
||||
moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
|
||||
snapshots:
|
||||
|
||||
moment@2.30.1: {}
|
Loading…
Reference in New Issue
Block a user