44 Commits

Author SHA1 Message Date
2dda4ee55a feat: 更新 Docker 构建推送工作流以根据操作系统和发布状态动态决定构建推送 2024-10-12 17:47:12 +08:00
e01a0b34d8 feat: 强制在所有平台上构建和推送 Docker 镜像 2024-10-12 17:43:40 +08:00
5195d74ff1 feat: 更新工作流以支持多操作系统环境和动态构建推送 2024-10-12 17:43:23 +08:00
6e58674f53 feat: 更新工作流以添加 GitHub 托管标准运行器的说明 [skip ci] 2024-10-12 17:38:23 +08:00
ced3572c0a feat: 更新工作流以支持多操作系统环境 2024-10-12 17:37:26 +08:00
3ef624f5d9 feat: 为工作流文件添加 pull_request 触发条件以支持路径过滤 2024-10-12 16:35:00 +08:00
f7f95de95a feat: 在 renovate.json 中添加自动合并所有依赖项的配置 2024-10-12 16:32:27 +08:00
a34f085e86 feat: 移除工作流配置中的分支限制以简化触发条件 2024-10-12 16:24:08 +08:00
54a6963676 feat: 移除 action.yml 中的调试信息以简化节点版本提取逻辑 2024-10-12 15:53:42 +08:00
64ad47eb05 feat: 在 action.yml 中添加空行以增强输出信息的可读性 2024-10-12 15:53:23 +08:00
dd74c0faa2 feat: 在 setup-node-environment.yml 中添加输出 .npmrc 文件内容的调试信息 2024-10-12 15:52:55 +08:00
62d536c82e feat: 在 action.yml 中添加调试信息以输出 node 版本的查找结果 2024-10-12 15:51:59 +08:00
a6aa3462f3 feat: 在 action.yml 中添加调试信息以便于提取 node 版本 2024-10-12 15:47:15 +08:00
c7455bfb3c feat: 更新 .npmrc 文件以添加注释并简化 node 版本提取逻辑 2024-10-12 15:46:48 +08:00
4c23f82657 feat: 取消注释 setup-node-environment.yml 中的 sed 命令,以移除 .npmrc 文件中的 use-node-version 行 2024-10-12 15:41:32 +08:00
4eb4324252 feat: 在 setup-node-environment.yml 中添加换行符以改善可读性 2024-10-12 15:40:33 +08:00
a9d3e3eb96 fix: 修复 .npmrc 文件末尾缺少换行符的问题 2024-10-12 15:39:33 +08:00
b81659bab6 feat: 取消注释 setup-node-environment.yml 中的 cat 命令,以输出 .npmrc 文件内容 2024-10-12 15:38:22 +08:00
f1edd9e2b5 feat: 注释掉 setup-node-environment.yml 中的 sed 和 cat 命令,以便于调试 2024-10-12 15:37:37 +08:00
1fcbdefb2f feat: 在 action.yml 中添加对 .npmrc 文件存在性的检查,以确保正确提取 Node 版本 2024-10-12 15:36:43 +08:00
55c4c305c0 feat: 更新 setup-node-environment.yml 和 action.yml,添加对未指定 Node 版本的默认处理 2024-10-12 15:27:46 +08:00
79f1925e81 feat: 在 setup-node-environment.yml 中添加调试信息,提取并输出 Node 版本 2024-10-12 15:25:21 +08:00
4f7bdd9fb4 feat: 更新 action.yml,添加对已安装 pnpm 的处理注释,并优化节点版本提取逻辑 2024-10-12 15:23:57 +08:00
7c58ef3294 feat: 更新 setup-node-environment.yml,添加第二个作业以检查 Node 和 PNPM 版本 2024-10-12 15:18:57 +08:00
9f1e52135c feat: 更新 setup-node-environment.yml,添加容器镜像矩阵和失败策略 2024-10-12 15:13:52 +08:00
ae2a20ab90 feat: 更新 setup-node-environment/action.yml,改进输出信息格式以增强可读性 2024-10-12 15:10:16 +08:00
47b2bb8d26 fix: 修正 setup-node-environment.yml 中的 pnpm 检查,确保脚本在未找到 pnpm 时不会失败 2024-10-12 15:06:17 +08:00
f9d3465703 feat: 更新 setup-node-environment.yml 和 action.yml,添加版本检查和输出信息;新增 .npmrc 文件以指定 Node.js 版本 2024-10-12 15:05:23 +08:00
3d8306ca70 feat: 更新 deploy-dist-to-surge/action.yml,添加部署描述 2024-10-12 14:41:00 +08:00
c1cee30ad3 feat: 更新 deploy-dist-to-surge.yml,动态生成 HTML 内容并改进输出信息 2024-10-12 14:23:09 +08:00
fa63868c18 fix: 修正 deploy-dist-to-surge.yml 中的引用路径 2024-10-12 14:20:04 +08:00
238392db7a feat: 删除 ci.yml,新增 setup-node-environment.yml 和 deploy-dist-to-surge.yml 工作流 2024-10-12 14:18:46 +08:00
edf12e5623 feat: 更新 setup-node-environment/action.yml,改用 Node.js 读取 packageManager 2024-10-12 12:14:44 +08:00
6ca5f9aef2 feat: 恢复 docker-build-push.yml 中的分支和路径配置 2024-10-10 11:14:57 +08:00
746c056e16 feat: 在 docker-build-push.yml 中新增 pull_request 触发器 2024-10-10 11:05:20 +08:00
bf2f20471c chore: 注释掉 docker-build-push.yml 中的分支和路径配置 2024-10-10 11:01:22 +08:00
5bd89bc7bb Create README.md 2024-10-09 14:34:11 +08:00
ad1ed515d9 feat: 更新 docker-build-push.yml,启用 GitHub Container Registry 登录步骤 2024-10-09 12:26:04 +08:00
2e7fd5567e feat: 重构 CI 流程,新增 docker-build-push 工作流
Some checks failed
持续集成 / setup-node-environment-test (push) Successful in 19s
docker-build-push / docker-build-push-test (push) Failing after 52s
2024-10-09 12:17:23 +08:00
ebb6f5dc6c feat: 测试 semantic 2024-10-09 11:57:19 +08:00
da7c4ac612 feat: 添加检查 .git 文件夹的步骤 2024-10-09 11:46:38 +08:00
aca6c13ecb fix: 修复 docker-build-push action.yml 中的 context 配置 2024-10-09 11:34:13 +08:00
a6b302e68a feat: 测试 semantic-release-action 2024-10-09 11:31:41 +08:00
dd22eed198 测试 Check .git folder 2024-10-09 11:27:20 +08:00
12 changed files with 229 additions and 59 deletions

View File

@ -1,53 +0,0 @@
name: 持续集成
on:
push:
env:
TZ: Asia/Shanghai
jobs:
setup-node-environment-test:
runs-on: ubuntu-latest
steps:
- uses: yanhao98/composite-actions/setup-node-environment@main
- name: Check Node and PNPM versions
run: |
set -x
which pnpm
docker-build-push-test:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: yanhao98/composite-actions/docker-build-push@main
id: docker-build-push
with:
build_file: ./docker-build-push/Dockerfile
build_platforms: linux/amd64
build_push: ${{ github.ref_type == 'tag' }}
build_load: true
metadata_images: |
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
ghcr.io/${{ github.repository }}
metadata_tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Check Docker image
run: |
set -x;
docker images;
docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;

View File

@ -0,0 +1,26 @@
on:
pull_request:
paths:
- "deploy-dist-to-surge.yml/**"
- ".github/workflows/deploy-dist-to-surge.yml"
push:
paths:
- "deploy-dist-to-surge.yml/**"
- ".github/workflows/deploy-dist-to-surge.yml"
env:
TZ: Asia/Shanghai
jobs:
job:
runs-on: ubuntu-latest
steps:
- name: 准备部署文件
run: |
mkdir dist
html="<!DOCTYPE html><html><body><h1>${{ github.event_name }}: ${{ github.sha }}</h1></body></html>"
echo $html > dist/index.html
- uses: yanhao98/composite-actions/deploy-dist-to-surge@main
id: surge_deploy
- name: Check Surge URL
run: |
echo "steps.surge_deploy.outputs.url: ${{ steps.surge_deploy.outputs.url }}"

58
.github/workflows/docker-build-push.yml vendored Normal file
View File

@ -0,0 +1,58 @@
on:
pull_request:
paths:
- "docker-build-push/**"
- ".github/workflows/docker-build-push.yml"
push:
paths:
- "docker-build-push/**"
- ".github/workflows/docker-build-push.yml"
env:
TZ: Asia/Shanghai
jobs:
job:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-15] # https://docs.github.com/zh/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#用于公共存储库的-github-托管的标准运行器
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@main
- uses: yanhao98/semantic-release-action@main
id: semantic
- name: Login to Docker Hub
if: steps.semantic.outputs.next_release_published == 'true'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: steps.semantic.outputs.next_release_published == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: yanhao98/composite-actions/docker-build-push@main
# if: steps.semantic.outputs.next_release_published == 'true'
id: docker-build-push
with:
build_file: ./Dockerfile.test
build_platforms: linux/amd64,linux/arm64
build_push: ${{ matrix.os == 'ubuntu-latest' && steps.semantic.outputs.next_release_published == 'true' }}
build_load: false
metadata_images: |
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
ghcr.io/${{ github.repository }}
metadata_tags: |
type=semver,pattern={{version}},value=${{ steps.semantic.outputs.next_release_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.next_release_version }}
type=semver,pattern={{major}},value=${{ steps.semantic.outputs.next_release_version }}
# - name: Check Docker image
# run: |
# set -x;
# docker images;
# docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;

View File

@ -0,0 +1,57 @@
on:
pull_request:
paths:
- "setup-node-environment/**"
- ".github/workflows/setup-node-environment.yml"
push:
paths:
- "setup-node-environment/**"
- ".github/workflows/setup-node-environment.yml"
env:
TZ: Asia/Shanghai
jobs:
job:
strategy:
fail-fast: false
matrix:
container-image: ["", "yanhao98/runner-images:pnpm"]
runs-on: ubuntu-latest
container:
image: ${{ matrix.container-image }}
steps:
- name: before
run: |
set -x;
which pnpm || true;
node -v;
- uses: yanhao98/composite-actions/setup-node-environment@main
- name: Check Node and PNPM versions
run: |
set -x;
which pnpm;
node -v;
pnpm node -v;
job-2: # 测试 .npmrc 文件没有 use-node-version 字段
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: before
run: |
set -x;
cat .npmrc;
sed -i '/use-node-version/d' .npmrc
node -v;
cat .npmrc;
- uses: yanhao98/composite-actions/setup-node-environment@main
- name: Check Node and PNPM versions
run: |
set -x;
which pnpm;
node -v;
pnpm node -v;

1
.npmrc Normal file
View File

@ -0,0 +1 @@
use-node-version=22.9.0 # https://pnpm.io/zh/npmrc#use-node-version

7
.releaserc.json Normal file
View File

@ -0,0 +1,7 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog"
]
}

1
README.md Normal file
View File

@ -0,0 +1 @@
- https://github.com/renovatebot/renovate/blob/81fc75630b0b43fb4b89a0b65c1086d487e65d2e/.github/actions/setup-node/action.yml

View File

@ -0,0 +1,22 @@
name: "Deploy dist to Surge"
description: "部署 dist 到 Surge"
outputs:
url:
description: "Preview URL"
value: ${{ steps.surge_deploy.outputs.url }}
runs:
using: "composite"
steps:
- name: 部署到 Surge
shell: bash
id: surge_deploy
# https://github.com/afc163/surge-preview
# https://github.com/Tencent/tdesign-vue-next/pull/1604#issuecomment-1236244550
# https://github.com/Tencent/tdesign-vue-next/blob/03036a19adccf4657d7792e3a61a6c6a7d902e3e/.github/workflows/preview-publish.yml
# https://github.com/Tencent/tdesign/blob/0c0c9b63897c05d10c58e1a1e36feda2cb99eca7/.github/workflows/preview.yml#L40
run: |
export DEPLOY_DOMAIN=https://${{ github.sha }}.surge.sh
cp dist/index.html dist/200.html
npx surge --project ./dist --domain $DEPLOY_DOMAIN --token d843de16b331c626f10771245c56ed93 # npx surge token
echo the preview URL is $DEPLOY_DOMAIN
echo "url=$DEPLOY_DOMAIN" >> $GITHUB_OUTPUT

View File

@ -33,7 +33,19 @@ outputs:
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Check .git folder
id: check-git-folder
shell: bash
run: |
if [ -d .git ]; then
echo "Found .git folder"
echo "git-folder-exists=true" >> $GITHUB_OUTPUT
else
echo "No .git folder found"
echo "git-folder-exists=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@main - uses: actions/checkout@main
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
with: with:
filter: blob:none filter: blob:none
show-progress: false show-progress: false
@ -42,7 +54,7 @@ runs:
id: meta id: meta
uses: docker/metadata-action@v5 # https://github.com/docker/metadata-action uses: docker/metadata-action@v5 # https://github.com/docker/metadata-action
with: with:
# context: git context: git
# flavor # flavor
images: ${{ inputs.metadata_images }} images: ${{ inputs.metadata_images }}
tags: ${{ inputs.metadata_tags }} tags: ${{ inputs.metadata_tags }}

View File

@ -1,7 +1,8 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "extends": [
"https://git.1-h.cc/examples/renovate-example/raw/branch/main/default.json5" "https://git.1-h.cc/examples/renovate-example/raw/branch/main/default.json5",
":automergeAll"
], ],
"dependencyDashboard": false "dependencyDashboard": false
} }

View File

@ -16,7 +16,19 @@ description: "Setup pnpm + Node.js + install dependencies"
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Check .git folder
id: check-git-folder
shell: bash
run: |
if [ -d .git ]; then
echo "Found .git folder"
echo "git-folder-exists=true" >> $GITHUB_OUTPUT
else
echo "No .git folder found"
echo "git-folder-exists=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@main - uses: actions/checkout@main
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
with: with:
# fetch-depth: 0 # zero stands for full checkout, which is required for semantic-release # fetch-depth: 0 # zero stands for full checkout, which is required for semantic-release
filter: blob:none # we don't need all blobs, only the full tree filter: blob:none # we don't need all blobs, only the full tree
@ -27,27 +39,53 @@ runs:
id: prepare id: prepare
run: | run: |
# Check package manager # Check package manager
packageManager=$(jq -r '.packageManager' package.json) packageManager=$(node -p "require('./package.json').packageManager")
echo "packageManager: $packageManager" echo "##########################################################"
echo "packageManager: $packageManager found in package.json"
echo ""
if [[ "$packageManager" == "pnpm"* ]]; then if [[ "$packageManager" == "pnpm"* ]]; then
echo "##########################################################"
# TODO: 还有一种情况就是镜像中已经安装了pnpm。
echo "setup-pnpm=true" echo "setup-pnpm=true"
echo ""
echo "setup-pnpm=true" >> $GITHUB_OUTPUT echo "setup-pnpm=true" >> $GITHUB_OUTPUT
fi fi
# Check if pnpm-lock.yaml exists # Check if pnpm-lock.yaml exists
if [[ -f "pnpm-lock.yaml" ]]; then if [[ -f "pnpm-lock.yaml" ]]; then
echo "pnpm-lock.yaml exists" echo "##########################################################"
echo "pnpm-lock.yaml exists. So pnpm install --frozen-lockfile will run"
echo ""
echo "pnpm-lock-exists=true" >> $GITHUB_OUTPUT echo "pnpm-lock-exists=true" >> $GITHUB_OUTPUT
echo "cache=pnpm" >> $GITHUB_OUTPUT echo "cache=pnpm" >> $GITHUB_OUTPUT
else else
echo "pnpm-lock.yaml does not exist" echo "pnpm-lock.yaml does not exist"
fi fi
# Extract the node version from the .npmrc file
nodeVersion=$(sed -n 's/.*use-node-version=\([0-9.]*\).*/\1/p' .npmrc)
if [[ -z "$nodeVersion" ]]; then
nodeVersion="lts/*"
echo "##########################################################"
echo "Node version not found in .npmrc. Using default: $nodeVersion"
echo ""
else
echo "##########################################################"
echo "Node version found in .npmrc: $nodeVersion"
echo ""
fi
echo "node-version=$nodeVersion" >> $GITHUB_OUTPUT
- uses: pnpm/action-setup@v4 # https://github.com/pnpm/action-setup?tab=readme-ov-file#inputs - uses: pnpm/action-setup@v4 # https://github.com/pnpm/action-setup?tab=readme-ov-file#inputs
if: steps.prepare.outputs.setup-pnpm == 'true' if: steps.prepare.outputs.setup-pnpm == 'true'
- uses: actions/setup-node@v4 # https://github.com/actions/setup-node?tab=readme-ov-file#usage - uses: actions/setup-node@v4 # https://github.com/actions/setup-node?tab=readme-ov-file#usage
with: with:
node-version: lts/* node-version: ${{ steps.prepare.outputs.node-version }}
cache: ${{ steps.prepare.outputs.cache }} cache: ${{ steps.prepare.outputs.cache }}
- name: 📦 Install Project Dependencies - name: 📦 Install Project Dependencies
if: steps.prepare.outputs.pnpm-lock-exists == 'true' if: steps.prepare.outputs.pnpm-lock-exists == 'true'