2020-06-04 10:38:30 +08:00
|
|
|
name: Publish Docker Image
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-07-01 22:49:29 +08:00
|
|
|
- rm
|
2020-06-04 10:38:30 +08:00
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
build:
|
|
|
|
name: Build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
2022-03-06 21:48:25 +08:00
|
|
|
uses: actions/checkout@v3
|
2020-06-04 10:57:43 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2020-06-04 10:38:30 +08:00
|
|
|
|
2020-10-17 13:46:05 +08:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
|
2020-06-04 10:38:30 +08:00
|
|
|
- name: Set up docker buildx
|
|
|
|
id: buildx
|
2020-10-17 13:46:05 +08:00
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
2020-06-04 10:38:30 +08:00
|
|
|
with:
|
2020-10-17 13:46:05 +08:00
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2020-11-10 15:19:12 +08:00
|
|
|
|
|
|
|
- name: Login to Github Package
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: Dreamacro
|
|
|
|
password: ${{ secrets.PACKAGE_TOKEN }}
|
2020-10-17 13:46:05 +08:00
|
|
|
|
|
|
|
- name: Build dev branch and push
|
2020-06-04 10:38:30 +08:00
|
|
|
if: github.ref == 'refs/heads/dev'
|
2020-10-17 13:46:05 +08:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
2021-12-02 21:12:45 +08:00
|
|
|
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
2020-10-17 13:46:05 +08:00
|
|
|
push: true
|
2020-11-10 15:19:12 +08:00
|
|
|
tags: 'dreamacro/clash:dev,ghcr.io/dreamacro/clash:dev'
|
2020-06-04 10:38:30 +08:00
|
|
|
|
2020-10-17 13:46:05 +08:00
|
|
|
- name: Get all docker tags
|
2020-06-04 10:38:30 +08:00
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
2022-03-06 21:48:25 +08:00
|
|
|
uses: actions/github-script@v6
|
2020-10-17 13:46:05 +08:00
|
|
|
id: tags
|
2020-06-04 10:38:30 +08:00
|
|
|
with:
|
|
|
|
script: |
|
2020-11-10 15:19:12 +08:00
|
|
|
const ref = `${context.payload.ref.replace(/\/?refs\/tags\//, '')}`
|
2020-10-17 13:46:05 +08:00
|
|
|
const tags = [
|
|
|
|
'dreamacro/clash:latest',
|
2020-11-10 15:19:12 +08:00
|
|
|
`dreamacro/clash:${ref}`,
|
|
|
|
'ghcr.io/dreamacro/clash:latest',
|
|
|
|
`ghcr.io/dreamacro/clash:${ref}`
|
2020-10-17 13:46:05 +08:00
|
|
|
]
|
|
|
|
return tags.join(',')
|
2020-06-04 10:38:30 +08:00
|
|
|
result-encoding: string
|
|
|
|
|
2020-10-17 13:46:05 +08:00
|
|
|
- name: Build release and push
|
2020-06-04 10:38:30 +08:00
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
2020-10-17 13:46:05 +08:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
2021-12-02 21:12:45 +08:00
|
|
|
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
2020-10-17 13:46:05 +08:00
|
|
|
push: true
|
|
|
|
tags: ${{steps.tags.outputs.result}}
|