增加 docker 镜像 #11
This file contains 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: Publish Multi-Architecture Docker Image | |
on: | |
push: | |
branches: | |
- main # 仅在推送到 main 分支时触发 | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
# 检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 设置 Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# 登录到 GitHub Packages | |
- name: Log in to GitHub Packages | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# 构建并推送多架构镜像 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest | |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} | |
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x |