chore: update Docker and release workflows for improved efficiency and security (#239)
This commit is contained in:
parent
b367d41b63
commit
8eb57836d8
3 changed files with 91 additions and 74 deletions
161
.github/workflows/docker.yml
vendored
161
.github/workflows/docker.yml
vendored
|
|
@ -1,88 +1,105 @@
|
||||||
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:
|
paths:
|
||||||
- "Dockerfile"
|
- "Dockerfile"
|
||||||
- "docker-compose.yml"
|
- "docker-compose.yml"
|
||||||
- "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 }}
|
||||||
cancel-in-progress: true
|
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:
|
pr-smoke:
|
||||||
name: Build and Push Docker Image
|
name: PR Docker Smoke
|
||||||
runs-on: ubuntu-latest
|
if: github.event_name == 'pull_request'
|
||||||
timeout-minutes: 25
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
timeout-minutes: 25
|
||||||
contents: read
|
permissions:
|
||||||
packages: write
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
steps:
|
- name: Set up Docker Buildx
|
||||||
- name: Checkout repository
|
uses: docker/setup-buildx-action@v3
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Extract metadata (tags, labels)
|
||||||
uses: docker/setup-buildx-action@v3
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=pr
|
||||||
|
|
||||||
- name: Log in to Container Registry
|
- name: Build smoke image
|
||||||
if: github.event_name != 'pull_request'
|
uses: docker/build-push-action@v5
|
||||||
uses: docker/login-action@v3
|
with:
|
||||||
with:
|
context: .
|
||||||
registry: ${{ env.REGISTRY }}
|
push: false
|
||||||
username: ${{ github.actor }}
|
load: true
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
tags: zeroclaw-pr-smoke:latest
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels)
|
- name: Verify image
|
||||||
id: meta
|
run: docker run --rm zeroclaw-pr-smoke:latest --version
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Build and push Docker image (push/tag)
|
publish:
|
||||||
if: github.event_name != 'pull_request'
|
name: Build and Push Docker Image
|
||||||
uses: docker/build-push-action@v5
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
runs-on: ubuntu-latest
|
||||||
context: .
|
timeout-minutes: 25
|
||||||
push: true
|
permissions:
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
contents: read
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
packages: write
|
||||||
cache-from: type=gha
|
steps:
|
||||||
cache-to: type=gha,mode=max
|
- name: Checkout repository
|
||||||
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build smoke image (PR only)
|
- name: Set up Docker Buildx
|
||||||
if: github.event_name == 'pull_request'
|
uses: docker/setup-buildx-action@v3
|
||||||
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)
|
- name: Log in to Container Registry
|
||||||
if: github.event_name == 'pull_request'
|
uses: docker/login-action@v3
|
||||||
run: |
|
with:
|
||||||
docker run --rm zeroclaw-pr-smoke:latest --version
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
||||||
|
|
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -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'
|
||||||
|
|
|
||||||
2
.github/workflows/security.yml
vendored
2
.github/workflows/security.yml
vendored
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue