chore: pipeline CI multi-arch + release notes #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/ci.yml | |
| name: CI (Build & Push Docker, Update Release) | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ "v*.*.*" ] | |
| workflow_dispatch: {} | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/gabs-redis-langcache | |
| DOCKERFILE: ./Dockerfile | |
| jobs: | |
| build-and-push: | |
| name: Build & Push (multi-arch) to Docker Hub + Release on tags | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # necessário para criar/atualizar Release quando for tag | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # QEMU para build multi-arquitetura (amd64 + arm64) | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Evita conflito com variável DOCKER_CONTEXT do Docker | |
| - name: Sanitize Docker context env | |
| run: echo "DOCKER_CONTEXT=" >> $GITHUB_ENV | |
| - name: Extract Docker metadata (tags & labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha | |
| type=ref,event=branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=semver,pattern={{version}} | |
| labels: | | |
| org.opencontainers.image.title=${{ github.event.repository.name }} | |
| org.opencontainers.image.source=${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Build & Push (linux/amd64, linux/arm64) | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE }} | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false | |
| # Somente em tags (ex.: v1.2.3): cria/atualiza Release no GitHub | |
| - name: Compose release notes | |
| if: startsWith(github.ref, 'refs/tags/') | |
| id: notes | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| DIGEST="${{ steps.build.outputs.digest }}" | |
| { | |
| echo "## 🐳 Docker Image" | |
| echo "" | |
| echo "- Registry: \`${{ env.REGISTRY }}\`" | |
| echo "- Image: \`${{ env.IMAGE_NAME }}\`" | |
| echo "- Tags publicados:" | |
| echo '${{ steps.meta.outputs.tags }}' | tr ' ' '\n' | sed 's/^/- /' | |
| echo "" | |
| echo "### Digest" | |
| echo "\`${DIGEST}\`" | |
| echo "" | |
| echo "### Plataformas" | |
| echo "- linux/amd64" | |
| echo "- linux/arm64" | |
| echo "" | |
| echo "### Commit" | |
| echo "\`${GITHUB_SHA}\`" | |
| } > release-notes.md | |
| cat release-notes.md | |
| - name: Create/Update GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release-notes.md | |
| body_path: release-notes.md | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}git status |