github.com/igoogolx/clash@v1.19.8/.github/workflows/docker.yml (about)

     1  name: Publish Docker Image
     2  on:
     3    push:
     4      branches:
     5        - dev
     6      tags:
     7        - '*'
     8  jobs:
     9  
    10    build:
    11      name: Build
    12      runs-on: ubuntu-latest
    13      steps:
    14  
    15        - name: Check out code into the Go module directory
    16          uses: actions/checkout@v3
    17          with:
    18            fetch-depth: 0
    19  
    20        - name: Set up QEMU
    21          uses: docker/setup-qemu-action@v2
    22          with:
    23            platforms: all
    24  
    25        - name: Set up docker buildx
    26          id: buildx
    27          uses: docker/setup-buildx-action@v2
    28          with:
    29            version: latest
    30  
    31        - name: Login to DockerHub
    32          uses: docker/login-action@v2
    33          with:
    34            username: ${{ secrets.DOCKER_USERNAME }}
    35            password: ${{ secrets.DOCKER_PASSWORD }}
    36        
    37        - name: Login to Github Package
    38          uses: docker/login-action@v2
    39          with:
    40            registry: ghcr.io
    41            username: Dreamacro
    42            password: ${{ secrets.PACKAGE_TOKEN }}
    43  
    44        - name: Build dev branch and push
    45          if: github.ref == 'refs/heads/dev'
    46          uses: docker/build-push-action@v4
    47          with:
    48            context: .
    49            platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
    50            push: true
    51            tags: 'dreamacro/clash:dev,ghcr.io/dreamacro/clash:dev'
    52            cache-from: type=gha
    53            cache-to: type=gha,mode=max
    54  
    55        - name: Get all docker tags
    56          if: startsWith(github.ref, 'refs/tags/')
    57          uses: actions/github-script@v6
    58          id: tags
    59          with:
    60            script: |
    61              const ref = context.payload.ref.replace(/\/?refs\/tags\//, '')
    62              const tags = [
    63                'dreamacro/clash:latest',
    64                `dreamacro/clash:${ref}`,
    65                'ghcr.io/dreamacro/clash:latest',
    66                `ghcr.io/dreamacro/clash:${ref}`
    67              ]
    68              return tags.join(',')
    69            result-encoding: string
    70  
    71        - name: Build release and push
    72          if: startsWith(github.ref, 'refs/tags/')
    73          uses: docker/build-push-action@v4
    74          with:
    75            context: .
    76            platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
    77            push: true
    78            tags: ${{steps.tags.outputs.result}}
    79            cache-from: type=gha
    80            cache-to: type=gha,mode=max