docker-firefox/.github/workflows/build-image.yml
wood chen 0ce91829a5 ci: 移除DockerHub登录和镜像推送的条件限制
之前DockerHub登录和镜像推送仅在`main`分支上执行,现移除条件限制,使所有分支都能推送镜像。这有助于在开发分支上测试和验证镜像构建流程。
2025-03-20 18:30:51 +08:00

74 lines
1.8 KiB
YAML

name: Docker image CI/CD
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_IMAGE_NAME: woodchen/firefox
PLATFORMS: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
on:
push:
branches: '*'
pull_request:
jobs:
build:
name: Build image
runs-on: ubuntu-latest
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Prepare
id: prep
run: |
# Set Docker container tag to latest
TAGS="${{ env.DOCKER_IMAGE_NAME }}:latest"
# Print results.
echo "::group::Results"
echo "Github reference: $GITHUB_REF"
echo "Docker container tag(s): $TAGS"
echo "::endgroup::"
# Export outputs.
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm,arm64,ppc64le,mips64,s390x
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=gha,scope=${{ env.DOCKER_IMAGE_NAME }}
cache-to: type=gha,mode=max,scope=${{ env.DOCKER_IMAGE_NAME }}