clash/.github/workflows/docker.yml

77 lines
2 KiB
YAML
Raw Normal View History

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