patch gh workflow with multiplattform builds #221
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
| name: push nuxt app to docker | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "README.md" | |
| - ".gitignore" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| actions: write | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete old package versions | |
| uses: actions/delete-package-versions@v5 | |
| with: | |
| package-name: ${{ github.event.repository.name }} | |
| package-type: container | |
| min-versions-to-keep: 3 | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=latest | |
| type=sha,format=long | |
| type=sha,format=short | |
| type=ref,event=branch | |
| - name: Cleanup old caches | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| CURRENT_HASH=$(cat Dockerfile package*.json 2>/dev/null | sha256sum | cut -d' ' -f1) | |
| echo "Current dependency hash: $CURRENT_HASH" | |
| gh cache list --json key,id | jq -r '.[] | select(.key | startswith("buildx-")) | select(.key | contains("'$CURRENT_HASH'") | not) | .id' | while read cache_id; do | |
| echo "Deleting old cache: $cache_id" | |
| gh cache delete $cache_id || true | |
| done | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| 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 | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 |