chore(version): 更新项目版本号- 将项目版本从 1.5.1 更新至1.5.2 #29
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
| name: 构建并推送 Docker 镜像到 GHCR | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| - name: 设置 Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: 登录到 GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 提取 Docker 镜像元数据(标签、元信息) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=sha | |
| - name: 构建并推送 Docker 镜像 | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| outputs: type=registry | |
| - name: 生成中文构建摘要 | |
| run: | | |
| echo "Docker 镜像构建摘要:" | |
| echo "镜像名称: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | |
| echo "标签: ${{ steps.meta.outputs.tags }}" | |
| echo "构建时间: $(date '+%Y年%m月%d日 %H:%M:%S')" | |
| echo "构建状态: 成功" | |
| echo "仓库: ${{ github.repository }}" | |
| echo "提交 SHA: ${{ github.sha }}" |