Merge pull request #2 from audiohacking/copilot/package-osx-app-with-… #1
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: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'Dockerfile' | |
| - 'docker-compose.yml' | |
| - 'backend/**' | |
| - 'frontend/**' | |
| - '.github/workflows/docker-publish.yml' | |
| release: | |
| types: [published] | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| build-and-push-ghcr: | |
| 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: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=semver,pattern={{version}} | |
| type=sha,prefix= | |
| - name: Build and push to GHCR | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false # Disable provenance attestations for consistency | |
| build-and-push-dockerhub: | |
| runs-on: ubuntu-latest | |
| needs: build-and-push-ghcr # Run after GHCR succeeds | |
| continue-on-error: true # Don't fail workflow if Docker Hub has issues | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Use native docker build/push instead of buildx (better for large layers) | |
| - name: Build Docker image | |
| run: | | |
| docker build -t ambsd/heartmula-studio:latest -t ambsd/heartmula-studio:${{ github.sha }} . | |
| - name: Push to Docker Hub (with retry) | |
| run: | | |
| for i in 1 2 3; do | |
| echo "Push attempt $i..." | |
| if docker push ambsd/heartmula-studio:latest && docker push ambsd/heartmula-studio:${{ github.sha }}; then | |
| echo "Push successful!" | |
| exit 0 | |
| fi | |
| echo "Push failed, waiting 30s before retry..." | |
| sleep 30 | |
| done | |
| echo "All push attempts failed" | |
| exit 1 |