add platforms: linux/amd64,linux/arm64 #3
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: Docker Image CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all # 启用所有支持的平台的模拟 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
buildkitd-flags: --allow-insecure-entitlement security.insecure | |
builder: default | |
use: true | |
- name: Log in to GitHub Container Registry | |
# 使用GITHUB_TOKEN登录,它允许操作推送容器镜像 | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./DockerfileForGitAction | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest | |
push: true |