Expand beta workflow branch matching for versioned tags. #24
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 to Docker Hub | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - beta | |
| - beta* | |
| - beta/* | |
| - "stable/*" | |
| paths-ignore: | |
| - "README.md" | |
| - "assets/**" | |
| - ".github/workflows/**" | |
| - "docs/**" | |
| - ".gitignore" | |
| - "LICENSE" | |
| # Prevent multiple builds from running concurrently on the same branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| DOCKER_IMAGE: ${{ secrets.DOCKERHUB_REPO }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| 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 }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| # Tag 'latest' and 'stable' when pushing to the main branch | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=raw,value=stable,enable=${{ github.ref == 'refs/heads/main' }} | |
| # Tag 'beta' when pushing to the beta or beta/* branches | |
| type=raw,value=beta,enable=${{ startsWith(github.ref, 'refs/heads/beta') }} | |
| # Extract the version from 'stable/*' branches (e.g., stable/1.0.0 -> 1.0.0) | |
| type=match,pattern=stable/(.*),group=1 | |
| # Extract the version from 'beta/*' branches (e.g., beta/1.0.0 -> beta-1.0.0) | |
| type=match,pattern=beta/(.*),group=1,prefix=beta- | |
| # Extract the version from 'beta1.0.0' branches (e.g., beta1.0.0 -> beta-1.0.0) | |
| type=match,pattern=beta(.*),group=1,prefix=beta-,enable=${{ startsWith(github.ref, 'refs/heads/beta') && github.ref != 'refs/heads/beta' }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| 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 |