name: Multi-Arch Docker Build & Push on: workflow_dispatch: inputs: tags: description: "Comma-separated list of tags (e.g. v1.0.1,latest,dev,beta)" required: true type: string push_dockerhub: description: "Push to Docker Hub" required: true type: boolean default: false push_ghcr: description: "Push to GitHub Container Registry" required: true type: boolean default: false push_quay: description: "Push to Quay.io" required: true type: boolean default: false jobs: build-and-push: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Parse tags id: tags run: | TAGS_INPUT="${{ github.event.inputs.tags }}" IFS=',' read -ra TAGS_ARRAY <<< "$TAGS_INPUT" for i in "${TAGS_ARRAY[@]}"; do CLEAN_TAG="$(echo "$i" | xargs)" # trim spaces echo "tag=$CLEAN_TAG" >> "$GITHUB_OUTPUT" echo "tags_list=${tags_list} $CLEAN_TAG" >> "$GITHUB_OUTPUT" done # Docker Hub login (optional) - name: Login to Docker Hub if: ${{ github.event.inputs.push_dockerhub == 'true' }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # GHCR login (optional) - name: Login to GHCR if: ${{ github.event.inputs.push_ghcr == 'true' }} uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GHCR_TOKEN }} # Quay.io login (optional) - name: Login to Quay.io if: ${{ github.event.inputs.push_quay == 'true' }} uses: docker/login-action@v3 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} # Push to Docker Hub - name: Build & Push to Docker Hub if: ${{ github.event.inputs.push_dockerhub == 'true' }} run: | set -e for tag in $(echo "${{ github.event.inputs.tags }}" | tr ',' ' '); do docker buildx build \ --platform linux/amd64,linux/arm64 \ --push \ -t docker.io/${{ secrets.DOCKERHUB_USERNAME }}/$(basename $GITHUB_REPOSITORY):$(echo "$tag" | xargs) . done continue-on-error: true # Push to GHCR - name: Build & Push to GHCR if: ${{ github.event.inputs.push_ghcr == 'true' }} run: | set -e REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') for tag in $(echo "${{ github.event.inputs.tags }}" | tr ',' ' '); do docker buildx build \ --platform linux/amd64,linux/arm64 \ --push \ -t ghcr.io/${REPO_NAME}:$(echo "$tag" | xargs) . done continue-on-error: true # Push to Quay.io - name: Build & Push to Quay.io if: ${{ github.event.inputs.push_quay == 'true' }} run: | set -e for tag in $(echo "${{ github.event.inputs.tags }}" | tr ',' ' '); do docker buildx build \ --platform linux/amd64,linux/arm64 \ --push \ -t quay.io/${{ secrets.QUAY_USERNAME }}/$(basename $GITHUB_REPOSITORY):$(echo "$tag" | xargs) . done continue-on-error: true