fix(ci): reduce Docker Actions cost without weakening PR gates (#232)
* fix(docker): update workflow to improve Docker image build and push process, add timeout * fix(licenses): allow Apache-2.0 WITH LLVM-exception
This commit is contained in:
parent
a04716d86c
commit
28ec4ae826
2 changed files with 76 additions and 53 deletions
128
.github/workflows/docker.yml
vendored
128
.github/workflows/docker.yml
vendored
|
|
@ -1,66 +1,88 @@
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
tags: ["v*"]
|
tags: ["v*"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- "Dockerfile"
|
||||||
|
- "docker-compose.yml"
|
||||||
|
- "dev/docker-compose.yml"
|
||||||
|
- "dev/sandbox/**"
|
||||||
|
- ".github/workflows/docker.yml"
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: docker-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
name: Build and Push Docker Image
|
name: Build and Push Docker Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
timeout-minutes: 25
|
||||||
contents: read
|
permissions:
|
||||||
packages: write
|
contents: read
|
||||||
continue-on-error: true # Don't block PRs on Docker build failures
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Container Registry
|
- name: Log in to Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels)
|
- name: Extract metadata (tags, labels)
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image (push/tag)
|
||||||
uses: docker/build-push-action@v5
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
uses: docker/build-push-action@v5
|
||||||
context: .
|
with:
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
context: .
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
push: true
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
cache-from: type=gha
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-to: type=gha,mode=max
|
cache-from: type=gha
|
||||||
platforms: linux/amd64,linux/arm64
|
cache-to: type=gha,mode=max
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|
||||||
- name: Verify image (PR only)
|
- name: Build smoke image (PR only)
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
run: |
|
uses: docker/build-push-action@v5
|
||||||
docker build -t zeroclaw-test .
|
with:
|
||||||
docker run --rm zeroclaw-test --version
|
context: .
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: zeroclaw-pr-smoke:latest
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
- name: Verify image (PR only)
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
run: |
|
||||||
|
docker run --rm zeroclaw-pr-smoke:latest --version
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ yanked = "warn"
|
||||||
allow = [
|
allow = [
|
||||||
"MIT",
|
"MIT",
|
||||||
"Apache-2.0",
|
"Apache-2.0",
|
||||||
|
"Apache-2.0 WITH LLVM-exception",
|
||||||
"BSD-2-Clause",
|
"BSD-2-Clause",
|
||||||
"BSD-3-Clause",
|
"BSD-3-Clause",
|
||||||
"ISC",
|
"ISC",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue