2020-06-04 10:38:30 +08: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 10:57:43 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2020-06-04 10:38:30 +08:00
|
|
|
|
|
|
|
- name: Set up docker buildx
|
|
|
|
id: buildx
|
|
|
|
uses: crazy-max/ghaction-docker-buildx@v2
|
|
|
|
with:
|
|
|
|
buildx-version: latest
|
|
|
|
skip-cache: false
|
|
|
|
qemu-version: latest
|
|
|
|
|
|
|
|
- name: Docker login
|
|
|
|
env:
|
|
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
run: |
|
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
|
|
|
|
|
|
|
- name: Docker buildx image and push on dev branch
|
|
|
|
if: github.ref == 'refs/heads/dev'
|
|
|
|
run: |
|
|
|
|
docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag dreamacro/clash:dev .
|
|
|
|
|
|
|
|
- name: Replace tag without `v`
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
uses: actions/github-script@v1
|
|
|
|
id: version
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
return context.payload.ref.replace(/\/refs\/tags\//v, '')
|
|
|
|
result-encoding: string
|
|
|
|
|
|
|
|
- name: Docker buildx image and push on release
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
run: |
|
|
|
|
docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag dreamacro/clash:${{steps.version.outputs.result}} .
|
|
|
|
docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag dreamacro/clash:latest .
|