chore: update Docker and release workflows for improved efficiency and security (#239)

This commit is contained in:
Will Sarg 2026-02-15 19:43:46 -05:00 committed by GitHub
parent b367d41b63
commit 8eb57836d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 91 additions and 74 deletions

View file

@ -12,6 +12,7 @@ on:
- "dev/docker-compose.yml" - "dev/docker-compose.yml"
- "dev/sandbox/**" - "dev/sandbox/**"
- ".github/workflows/docker.yml" - ".github/workflows/docker.yml"
workflow_dispatch:
concurrency: concurrency:
group: docker-${{ github.event.pull_request.number || github.ref }} group: docker-${{ github.event.pull_request.number || github.ref }}
@ -22,14 +23,50 @@ env:
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
build-and-push: pr-smoke:
name: PR Docker Smoke
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=pr
- name: Build smoke image
uses: docker/build-push-action@v5
with:
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
run: docker run --rm zeroclaw-pr-smoke:latest --version
publish:
name: Build and Push Docker Image name: Build and Push Docker Image
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 25 timeout-minutes: 25
permissions: permissions:
contents: read contents: read
packages: write packages: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -38,7 +75,6 @@ jobs:
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'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
@ -52,14 +88,12 @@ jobs:
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=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 (push/tag) - name: Build and push Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
@ -69,20 +103,3 @@ jobs:
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }} platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
- name: Build smoke image (PR only)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
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

View file

@ -40,7 +40,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Build release - name: Build release
run: cargo build --release --target ${{ matrix.target }} run: cargo build --release --locked --target ${{ matrix.target }}
- name: Check binary size (Unix) - name: Check binary size (Unix)
if: runner.os != 'Windows' if: runner.os != 'Windows'

View file

@ -21,7 +21,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit - name: Install cargo-audit
run: cargo install cargo-audit run: cargo install --locked cargo-audit --version 0.22.1
- name: Run cargo-audit - name: Run cargo-audit
run: cargo audit run: cargo audit