github.com/Mrs4s/go-cqhttp@v1.2.0/.github/workflows/build_docker_image.yml (about)

     1  name: Build And Push Docker Image
     2  
     3  on:
     4    push:
     5      branches:
     6        - 'master'
     7        - 'dev'
     8      # Sequence of patterns matched against refs/tags
     9      tags:
    10        - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
    11  
    12    workflow_dispatch:
    13  
    14  jobs:
    15    build:
    16  
    17      runs-on: ubuntu-latest
    18  
    19      permissions:
    20        packages: write
    21        contents: read
    22  
    23      steps:
    24        - uses: actions/checkout@v3
    25  
    26        - name: Set time zone
    27          uses: szenius/set-timezone@v1.1
    28          with:
    29            timezoneLinux: "Asia/Shanghai"
    30            timezoneMacos: "Asia/Shanghai"
    31            timezoneWindows: "China Standard Time"
    32  
    33        # # 如果有 dockerhub 账户,可以在github的secrets中配置下面两个,然后取消下面注释的这几行,并在meta步骤的images增加一行 ${{ github.repository }}
    34        # - name: Login to DockerHub
    35        #   uses: docker/login-action@v1
    36        #   with:
    37        #     username: ${{ secrets.DOCKERHUB_USERNAME }}
    38        #     password: ${{ secrets.DOCKERHUB_TOKEN }}
    39  
    40        - name: Login to GHCR
    41          uses: docker/login-action@v2
    42          with:
    43            registry: ghcr.io
    44            username: ${{ github.repository_owner }}
    45            password: ${{ secrets.GITHUB_TOKEN }}
    46  
    47        - name: Extract metadata (tags, labels) for Docker
    48          id: meta
    49          uses: docker/metadata-action@v4
    50          with:
    51            images: |
    52              ghcr.io/${{ github.repository }}
    53            # generate Docker tags based on the following events/attributes
    54            #   nightly, master, pr-2, 1.2.3, 1.2, 1
    55            tags: |
    56              type=schedule,pattern=nightly
    57              type=edge
    58              type=ref,event=branch
    59              type=ref,event=pr
    60              type=semver,pattern={{version}}
    61              type=semver,pattern={{major}}.{{minor}}
    62              type=semver,pattern={{major}}
    63  
    64        - name: Set up QEMU
    65          uses: docker/setup-qemu-action@v2
    66  
    67        - name: Set up Docker Buildx
    68          uses: docker/setup-buildx-action@v2
    69  
    70        - name: Build and push
    71          id: docker_build
    72          uses: docker/build-push-action@v4
    73          with:
    74            context: .
    75            push: ${{ github.event_name != 'pull_request' }}
    76            tags: ${{ steps.meta.outputs.tags }}
    77            labels: ${{ steps.meta.outputs.labels }}
    78            cache-from: type=gha
    79            cache-to: type=gha,mode=max
    80            platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x