Enhance Docker image build workflow #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: Docker Image CI | ||
| on: | ||
| push: | ||
| branches: [ "master" ] | ||
| pull_request: | ||
| branches: [ "master" ] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Step 1 — Checkout code | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
| # Step 2 — Login to DockerHub | ||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| # Step 3 — Setup Buildx (for caching + multi-platform) | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| # Step 4 — Build and Push | ||
| - name: Build & Push Docker Image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| platforms: linux/amd64 | ||
| tags: | | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/streamvision:latest | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/streamvision:${{ github.run_number }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| # (Optional) Step 5 — Output final image tag | ||
| - name: Show Image Tag | ||
| run: echo "Pushed version: ${{ secrets.DOCKERHUB_USERNAME }}/streamvision:${{ github.run_number }}" | ||