github.com/yaling888/clash@v1.53.0/.github/workflows/docker.yml (about)

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