Update
This commit is contained in:
156
.github/workflows/docker-build.yml
vendored
156
.github/workflows/docker-build.yml
vendored
@ -2,19 +2,19 @@ name: Build and Publish Docker Images
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, develop ]
|
branches: [main, develop]
|
||||||
tags: [ 'v*' ]
|
tags: ["v*"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
platforms:
|
platforms:
|
||||||
description: 'Platforms to build (comma-separated)'
|
description: "Platforms to build (comma-separated)"
|
||||||
required: false
|
required: false
|
||||||
default: 'linux/amd64,linux/arm64'
|
default: "linux/amd64,linux/arm64"
|
||||||
type: string
|
type: string
|
||||||
push_to_registry:
|
push_to_registry:
|
||||||
description: 'Push to registry'
|
description: "Push to registry"
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
type: boolean
|
type: boolean
|
||||||
@ -22,7 +22,6 @@ on:
|
|||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME_1: ${{ github.repository_owner }}/voice-rss-summary
|
IMAGE_NAME_1: ${{ github.repository_owner }}/voice-rss-summary
|
||||||
IMAGE_NAME_2: ${{ github.repository_owner }}/voicersssummary
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -32,83 +31,82 @@ jobs:
|
|||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- 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
|
- name: Extract metadata
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_1 }}
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_1 }}
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_2 }}
|
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: Determine platforms
|
- name: Determine platforms
|
||||||
id: platforms
|
id: platforms
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
echo "platforms=${{ github.event.inputs.platforms }}" >> $GITHUB_OUTPUT
|
echo "platforms=${{ github.event.inputs.platforms }}" >> $GITHUB_OUTPUT
|
||||||
elif [ "${{ github.event_name }}" = "pull_request" ]; then
|
elif [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||||
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
|
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
|
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Determine push setting
|
- name: Determine push setting
|
||||||
id: push
|
id: push
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
echo "push=${{ github.event.inputs.push_to_registry }}" >> $GITHUB_OUTPUT
|
echo "push=${{ github.event.inputs.push_to_registry }}" >> $GITHUB_OUTPUT
|
||||||
elif [ "${{ github.event_name }}" = "pull_request" ]; then
|
elif [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||||
echo "push=false" >> $GITHUB_OUTPUT
|
echo "push=false" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "push=true" >> $GITHUB_OUTPUT
|
echo "push=true" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: ${{ steps.platforms.outputs.platforms }}
|
platforms: ${{ steps.platforms.outputs.platforms }}
|
||||||
push: ${{ steps.push.outputs.push }}
|
push: ${{ steps.push.outputs.push }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
build-args: |
|
build-args: |
|
||||||
BUILDKIT_INLINE_CACHE=1
|
BUILDKIT_INLINE_CACHE=1
|
||||||
|
|
||||||
- name: Generate summary
|
- name: Generate summary
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Event**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Event**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Ref**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Ref**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Platforms**: ${{ steps.platforms.outputs.platforms }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Platforms**: ${{ steps.platforms.outputs.platforms }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Push to registry**: ${{ steps.push.outputs.push }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Push to registry**: ${{ steps.push.outputs.push }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "### Images built:" >> $GITHUB_STEP_SUMMARY
|
echo "### Images built:" >> $GITHUB_STEP_SUMMARY
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
|
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
Reference in New Issue
Block a user