name: Build and Push Docker Image permissions: contents: read packages: write on: push: branches: - main - develop pull_request: branches: - main jobs: build-and-push: runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push uses: docker/build-push-action@v4 with: # Build for multiple platforms platforms: linux/amd64,linux/arm64 # Path to Docker context and Dockerfile (adjust if needed) context: . file: Dockerfile # Push images to both Docker Hub and GHCR push: true tags: | ghcr.io/${{ github.repository_owner }}/docdice:latest ghcr.io/${{ github.repository_owner }}/docdice:${{ github.sha }} # Caching options to speed up subsequent builds cache-from: type=gha cache-to: type=gha,mode=max