diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 4d4de73..b947163 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,19 +2,19 @@ name: Build and Publish Docker Images on: push: - branches: [ main, develop ] - tags: [ 'v*' ] + branches: [main, develop] + tags: ["v*"] pull_request: - branches: [ main ] + branches: [main] workflow_dispatch: inputs: platforms: - description: 'Platforms to build (comma-separated)' + description: "Platforms to build (comma-separated)" required: false - default: 'linux/amd64,linux/arm64' + default: "linux/amd64,linux/arm64" type: string push_to_registry: - description: 'Push to registry' + description: "Push to registry" required: false default: true type: boolean @@ -22,7 +22,6 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME_1: ${{ github.repository_owner }}/voice-rss-summary - IMAGE_NAME_2: ${{ github.repository_owner }}/voicersssummary jobs: build: @@ -32,83 +31,82 @@ jobs: packages: write steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Log in to Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_1 }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_2 }} - 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: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_1 }} + 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: Determine platforms - id: platforms - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "platforms=${{ github.event.inputs.platforms }}" >> $GITHUB_OUTPUT - elif [ "${{ github.event_name }}" = "pull_request" ]; then - echo "platforms=linux/amd64" >> $GITHUB_OUTPUT - else - echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT - fi + - name: Determine platforms + id: platforms + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "platforms=${{ github.event.inputs.platforms }}" >> $GITHUB_OUTPUT + elif [ "${{ github.event_name }}" = "pull_request" ]; then + echo "platforms=linux/amd64" >> $GITHUB_OUTPUT + else + echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT + fi - - name: Determine push setting - id: push - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "push=${{ github.event.inputs.push_to_registry }}" >> $GITHUB_OUTPUT - elif [ "${{ github.event_name }}" = "pull_request" ]; then - echo "push=false" >> $GITHUB_OUTPUT - else - echo "push=true" >> $GITHUB_OUTPUT - fi + - name: Determine push setting + id: push + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "push=${{ github.event.inputs.push_to_registry }}" >> $GITHUB_OUTPUT + elif [ "${{ github.event_name }}" = "pull_request" ]; then + echo "push=false" >> $GITHUB_OUTPUT + else + echo "push=true" >> $GITHUB_OUTPUT + fi - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - platforms: ${{ steps.platforms.outputs.platforms }} - push: ${{ steps.push.outputs.push }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - BUILDKIT_INLINE_CACHE=1 + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{ steps.platforms.outputs.platforms }} + push: ${{ steps.push.outputs.push }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 - - name: Generate summary - if: always() - run: | - echo "## Build Summary" >> $GITHUB_STEP_SUMMARY - echo "- **Event**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY - echo "- **Ref**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY - echo "- **Platforms**: ${{ steps.platforms.outputs.platforms }}" >> $GITHUB_STEP_SUMMARY - echo "- **Push to registry**: ${{ steps.push.outputs.push }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Images built:" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY \ No newline at end of file + - name: Generate summary + if: always() + run: | + echo "## Build Summary" >> $GITHUB_STEP_SUMMARY + echo "- **Event**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY + echo "- **Ref**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY + echo "- **Platforms**: ${{ steps.platforms.outputs.platforms }}" >> $GITHUB_STEP_SUMMARY + echo "- **Push to registry**: ${{ steps.push.outputs.push }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Images built:" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY