name: Build Docker Images

on:
  workflow_dispatch:

jobs:
  dockerhub:
    runs-on: ubuntu-latest

    steps:
      - name: checkout sources
        uses: actions/checkout@v2.3.4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to Docker Hub
        uses: docker/login-action@v1.10.0
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          platforms: linux/amd64,linux/arm64,linux/s390x,linux/arm/v7
          push: true
          tags: user/app:latest
  • Access Token可以通过Docker HubAccount Settings->Security->New Access Token创建,然后通过GitHub仓库的Settings->Secrets->New repository secret分别创建DOCKERHUB_USERNAMEDOCKERHUB_TOKEN
  • tags: user/app:latest中的userapp需要修改为实际的用户名镜像名