From baabf21340285747313626201065217e94d4995d Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Sat, 17 Oct 2020 13:46:05 +0800 Subject: [PATCH] Chore: update github workflow --- .github/workflows/docker.yml | 54 +++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b6212dfc..6c15c03f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -17,36 +17,50 @@ jobs: with: fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + - name: Set up docker buildx id: buildx - uses: crazy-max/ghaction-docker-buildx@v3 + uses: docker/setup-buildx-action@v1 with: - buildx-version: latest - qemu-version: latest + 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 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build dev branch and push 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 . + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: 'dreamacro/clash:dev' - - name: Replace tag without `v` + - name: Get all docker tags if: startsWith(github.ref, 'refs/tags/') uses: actions/github-script@v3 - id: version + id: tags with: script: | - return context.payload.ref.replace(/\/?refs\/tags\/v/, '') + const tags = [ + 'dreamacro/clash:latest', + `dreamacro/clash:${context.payload.ref.replace(/\/?refs\/tags\//, '')}` + ] + return tags.join(',') result-encoding: string - - name: Docker buildx image and push on release + - name: Build release and push 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 . + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: ${{steps.tags.outputs.result}}