chore: disable build cache #11
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 Actions Workflow for Docker Image Build and Push | |
| # This workflow builds and pushes a Docker image to GitHub Container Registry (ghcr.io) | |
| # when changes are pushed to main branch OR when a release is created | |
| name: Build and Push Docker Image | |
| on: | |
| # Trigger on push to main branch | |
| push: | |
| branches: | |
| - main | |
| # Trigger on release creation | |
| release: | |
| types: [published] | |
| env: | |
| REGISTRY: ghcr.io | |
| # This will be: ghcr.io/username/repo-name (automatically lowercased) | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| # For releases: use the release tag name | |
| type=ref,event=tag | |
| # For main branch: use 'latest' | |
| 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 }} | |
| # Temporarily remove cache to force clean build | |
| # cache-from: type=gha | |
| # cache-to: type=gha,mode=max | |
| no-cache: true | |
| - name: Display pushed tags | |
| run: | | |
| echo "Successfully pushed image with tags:" | |
| echo "${{ steps.meta.outputs.tags }}" | |
| - name: Delete untagged images | |
| uses: actions/delete-package-versions@v5 | |
| continue-on-error: true | |
| with: | |
| package-name: ${{ github.event.repository.name }} | |
| package-type: 'container' | |
| min-versions-to-keep: 0 | |
| delete-only-untagged-versions: 'true' |