ci: dynamic import for simple-git
This commit is contained in:
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -30,24 +30,24 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|
||||||
|
# deploy to edgeone
|
||||||
|
# see https://edgeone.ai/zh/document/180255338996572160?product=edgedeveloperplatform
|
||||||
|
- name: Deploy to EdgeOne Pages
|
||||||
|
run: npx edgeone pages deploy dist -n cook-yunyoujun-cn -t ${{ secrets.EDGEONE_API_TOKEN }}
|
||||||
|
env:
|
||||||
|
EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: .output/public/
|
files: dist
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Cook Dist
|
name: Cook Dist
|
||||||
path: .output/public/
|
path: dist
|
||||||
|
|
||||||
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
|
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
|
||||||
# deploy to edgeone
|
|
||||||
# see https://edgeone.ai/zh/document/180255338996572160?product=edgedeveloperplatform
|
|
||||||
- name: Deploy to EdgeOne Pages
|
|
||||||
run: npx edgeone pages deploy .output/public -n cook-yunyoujun-cn -t ${{ secrets.EDGEONE_API_TOKEN }}
|
|
||||||
env:
|
|
||||||
EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ RUN npm install -g pnpm
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN pnpm install && pnpm run generate
|
RUN pnpm install && pnpm run build
|
||||||
|
|
||||||
FROM nginx:stable-alpine
|
FROM nginx:stable-alpine
|
||||||
COPY --from=builder /app/.output/public /usr/share/nginx/html
|
COPY --from=builder /app/.output/public /usr/share/nginx/html
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ import { appDescription } from './app/constants/index'
|
|||||||
// VITE_COMMIT_REF: process.env.CF_PAGES_COMMIT_SHA || '',
|
// VITE_COMMIT_REF: process.env.CF_PAGES_COMMIT_SHA || '',
|
||||||
// })
|
// })
|
||||||
|
|
||||||
import { getLatestCommit } from './scripts/git'
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const { getLatestCommit } = await import('./scripts/git')
|
||||||
const latestCommit = await getLatestCommit()
|
const latestCommit = await getLatestCommit()
|
||||||
/**
|
/**
|
||||||
* CF_PAGES_COMMIT_SHA is Cloudflare Pages env
|
* CF_PAGES_COMMIT_SHA is Cloudflare Pages env
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { simpleGit } from 'simple-git'
|
import { simpleGit } from 'simple-git'
|
||||||
|
|
||||||
const git = simpleGit()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get git repo latest commit
|
* get git repo latest commit
|
||||||
*/
|
*/
|
||||||
export async function getLatestCommit() {
|
export async function getLatestCommit() {
|
||||||
|
const git = simpleGit()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const log = await git.log({ maxCount: 1 })
|
const log = await git.log({ maxCount: 1 })
|
||||||
return log.latest
|
return log.latest
|
||||||
|
|||||||
Reference in New Issue
Block a user