Skip to content

Commit

Permalink
ci(build_docker): merge build_docker into release_docker workflow (#7755
Browse files Browse the repository at this point in the history
)

* feat(ci): merge build_docker workflow into release_docker

* fix(ci): logics of docker meta
  • Loading branch information
Mmx233 authored Jan 1, 2025
1 parent e4439e6 commit 687124c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 130 deletions.
126 changes: 0 additions & 126 deletions .github/workflows/build_docker.yml

This file was deleted.

28 changes: 24 additions & 4 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@ on:
push:
tags:
- 'v*'
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
IMAGE_REGISTRY: 'xhofe/alist'
REGISTRY: 'xhofe/alist'
REGISTRY_USERNAME: 'xhofe'
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
ARTIFACT_NAME: 'binaries_docker_release'
RELEASE_PLATFORMS: 'linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64'
IMAGE_PUSH: ${{ github.event_name == 'push' }}
IMAGE_IS_PROD: ${{ github.ref_type == 'tag' }}
IMAGE_TAGS_BETA: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=beta,enable={{is_default_branch}}
jobs:
build_binary:
Expand Down Expand Up @@ -85,18 +102,21 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
if: env.IMAGE_PUSH == 'true'
uses: docker/login-action@v3
with:
logout: true
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_REGISTRY }}
images: ${{ env.REGISTRY }}
tags: ${{ env.IMAGE_IS_PROD == 'true' && '' || env.IMAGE_TAGS_BETA }}
flavor: |
latest=true
${{ env.IMAGE_IS_PROD == 'true' && 'latest=true' || '' }}
${{ matrix.tag_favor }}
- name: Build and push
Expand All @@ -105,7 +125,7 @@ jobs:
with:
context: .
file: Dockerfile.ci
push: true
push: ${{ env.IMAGE_PUSH == 'true' }}
build-args: ${{ matrix.build_arg }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down

0 comments on commit 687124c

Please sign in to comment.