mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-14 02:09:56 +08:00
fix(CI): 修复流水线构建镜像异常 (#68)
This commit is contained in:
6
.github/workflows/CD.yaml
vendored
6
.github/workflows/CD.yaml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
## 部署到Github-Pages
|
||||
deploy-github:
|
||||
name: "部署到Github-Pages"
|
||||
runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
@@ -66,7 +66,7 @@ jobs:
|
||||
## 部署到vercel平台
|
||||
deploy-vercel:
|
||||
name: "部署到Vercel平台"
|
||||
runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == '142vip/408CSFamily'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
## 版本发布
|
||||
release:
|
||||
name: "Github版本发布"
|
||||
runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
## 主库master、next且执行release更新时执行
|
||||
if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):')
|
||||
|
||||
|
||||
36
.github/workflows/CI.yml
vendored
36
.github/workflows/CI.yml
vendored
@@ -17,10 +17,17 @@ on:
|
||||
schedule:
|
||||
- cron: "0 0 1 * *"
|
||||
|
||||
# 环境变量
|
||||
env:
|
||||
# 阿里云仓库信息
|
||||
REGISTRY: registry.cn-hangzhou.aliyuncs.com
|
||||
UserName: 142vip
|
||||
|
||||
|
||||
jobs:
|
||||
install-init:
|
||||
name: "依赖安装初始化"
|
||||
runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
@@ -59,7 +66,7 @@ jobs:
|
||||
|
||||
Base-Build:
|
||||
name: "基础编译构建"
|
||||
runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- install-init
|
||||
steps:
|
||||
@@ -95,9 +102,7 @@ jobs:
|
||||
|
||||
Build-Docker-Image:
|
||||
name: "构建Docker镜像"
|
||||
runs-on: macos-latest
|
||||
needs:
|
||||
- install-init
|
||||
runs-on: ubuntu-latest
|
||||
## 主库且tag更新时执行
|
||||
if: github.repository == '142vip/408CSFamily' && startsWith(github.ref, 'refs/tags/v')
|
||||
permissions:
|
||||
@@ -112,6 +117,12 @@ jobs:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login Docker
|
||||
run: |
|
||||
docker version
|
||||
@@ -121,23 +132,18 @@ jobs:
|
||||
--password=${{ secrets.DOCKER_PASSWORD }} \
|
||||
${{env.REGISTRY}}
|
||||
|
||||
- name: Restore Dependencies From Cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
## 支持思维导图转化
|
||||
- name: Build Mark-Map
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
./scripts/mark-map
|
||||
./scripts/ci
|
||||
|
||||
## 构建,支持domain
|
||||
- name: Build To Dist
|
||||
run: |
|
||||
./scripts/bundle build_proxy
|
||||
./scripts/bundle build
|
||||
|
||||
## 快速构建并推送
|
||||
- name: Push Docker Image
|
||||
run: |
|
||||
./scripts/bundle image_faster
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ ARG CONTAINER_BUILD
|
||||
WORKDIR /apps
|
||||
COPY . .
|
||||
|
||||
RUN echo $CONTAINER_BUILD
|
||||
RUN echo $CONTAINER_BUILD;
|
||||
|
||||
## 基于容器自动构建
|
||||
RUN if [ "$CONTAINER_BUILD" = "true" ]; then \
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* - ./scripts/bundle 交互式选择执行的命令
|
||||
*/
|
||||
|
||||
const { execShell } = require('./.exec')
|
||||
const { Select } = require('enquirer')
|
||||
const {execShell} = require('./.exec')
|
||||
const {Select} = require('enquirer')
|
||||
|
||||
const packageVersion = require('../package.json').version
|
||||
const projectName = '408CSFamily'
|
||||
@@ -28,7 +28,7 @@ const imageName = `${repoAddress}:${projectName}-${packageVersion}`
|
||||
* @param needProxy
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function getBuildImageScript({ containerBuild, preBuild, needProxy = false }) {
|
||||
function getBuildImageScript({containerBuild, preBuild, needProxy = false}) {
|
||||
// 基础构建脚本
|
||||
let baseBuildScript = ''
|
||||
|
||||
@@ -37,17 +37,17 @@ function getBuildImageScript({ containerBuild, preBuild, needProxy = false }) {
|
||||
}
|
||||
|
||||
return [
|
||||
// 构建镜像
|
||||
`
|
||||
// 构建镜像
|
||||
`
|
||||
${baseBuildScript}
|
||||
docker build \
|
||||
--build-arg APP_VERSION=${packageVersion} \
|
||||
--build-arg CONTAINER_BUILD=${containerBuild} \
|
||||
-t ${imageName} .
|
||||
`,
|
||||
// 推送镜像
|
||||
`
|
||||
if [[ "$(docker images -q ${imageName} 2> /dev/null)" != "" ]];then
|
||||
// 推送镜像
|
||||
`
|
||||
if [ "$(docker images -q ${imageName} 2> /dev/null)" != "" ];then
|
||||
## 推送
|
||||
docker push ${imageName}
|
||||
echo "---------------- 上传镜像成功,删除本地镜像 ---------------- "
|
||||
@@ -125,13 +125,15 @@ async function getScriptCommand() {
|
||||
scriptCommand = await prompt.run()
|
||||
} else {
|
||||
// 命中支持的脚本
|
||||
if (Object.keys(SupportScripts).includes(scriptName)) { scriptCommand = SupportScripts[scriptName] }
|
||||
if (Object.keys(SupportScripts).includes(scriptName)) {
|
||||
scriptCommand = SupportScripts[scriptName]
|
||||
}
|
||||
}
|
||||
return scriptCommand
|
||||
}
|
||||
|
||||
|
||||
;(async() => {
|
||||
;(async () => {
|
||||
const scriptCommand = await getScriptCommand()
|
||||
await execShell(scriptCommand)
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user