发布编辑器界面 n8n@2.4.8 #44
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 构建并发布 Docker 镜像到 DockerHub | |
| name: 发布 Docker 镜像 | |
| on: | |
| # 当创建新的 Release 时自动触发 | |
| release: | |
| types: [published] | |
| # 支持手动触发,需要提供标签名称 | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag 名称 (例如: n8n@2.0.3)' | |
| required: true | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| environment: test | |
| steps: | |
| # 检出指定标签的代码 | |
| - name: 检出标签代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }} | |
| fetch-depth: 0 | |
| # 设置 Docker Buildx 以支持多架构构建 | |
| - name: 设置 Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 登录到 DockerHub | |
| - name: 登录 DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # 提取版本号:优先使用手动输入,其次使用 GITHUB_REF,最后获取最新标签 | |
| - name: 提取版本号 | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| # 手动触发:使用输入的标签 | |
| RAW_TAG="${{ github.event.inputs.tag }}" | |
| elif [ "${{ github.event_name }}" = "release" ]; then | |
| # Release 触发:使用 GITHUB_REF | |
| RAW_TAG=${GITHUB_REF##*/} | |
| else | |
| # 其他情况:获取 git 仓库中最新的标签 | |
| RAW_TAG=$(git tag --sort=-version:refname | head -n 1) | |
| if [ -z "$RAW_TAG" ]; then | |
| echo "❌ 错误:无法获取标签" | |
| exit 1 | |
| fi | |
| fi | |
| VERSION=${RAW_TAG#n8n@} | |
| echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "✅ 版本号: $VERSION (来源: ${{ github.event_name }})" | |
| # 构建并推送多架构 Docker 镜像(支持 AMD64 和 ARM64) | |
| - name: 构建并推送 Docker 镜像 | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| --build-arg VERSION=$RELEASE_VERSION \ | |
| -t funcodingdev/n8n-chinese:$RELEASE_VERSION \ | |
| -t funcodingdev/n8n-chinese:latest \ | |
| --push \ | |
| . |