clash/.github/workflows/docker.yml

67 lines
1.7 KiB
YAML
Raw Normal View History

2020-06-04 02:38:30 +00:00
name: Publish Docker Image
on:
push:
branches:
- dev
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: 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'
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/')
2020-08-30 15:06:21 +00:00
uses: actions/github-script@v3
2020-10-17 05:46:05 +00:00
id: tags
2020-06-04 02:38:30 +00:00
with:
script: |
2020-10-17 05:46:05 +00:00
const tags = [
'dreamacro/clash:latest',
`dreamacro/clash:${context.payload.ref.replace(/\/?refs\/tags\//, '')}`
]
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}}