name: Docker Multi-Architecture Image CI on: push: pull_request: permissions: packages: write env: APP_NAME: rdtclient DOCKER_FILE: ./Dockerfile ENABLE_DOCKERHUB: 1 ENABLE_GHCR: 1 concurrency: ${{ github.sha }} jobs: build: strategy: matrix: config: - arch: amd64 runs-on: ubuntu-latest platform: linux/amd64 - arch: arm64 runs-on: ubuntu-24.04-arm platform: linux/arm64/v8 runs-on: ${{ matrix.config.runs-on }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Docker Metadata action id: meta uses: docker/metadata-action@v5 with: images: | ${{ github.ref_type == 'tag' && format('{0}/{1}', secrets.DOCKERHUB_USERNAME, env.APP_NAME) || ''}} ghcr.io/${{ github.repository_owner }}/${{ env.APP_NAME }} tags: | type=schedule type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha - name: Build and save image uses: docker/build-push-action@v5 with: context: . file: ${{ env.DOCKER_FILE }} platforms: ${{ matrix.config.platform }} push: false load: true outputs: type=docker,dest=${{ runner.temp }}/${{ matrix.config.arch }}.tar tags: ${{ env.APP_NAME }}:${{ github.sha }}-${{ matrix.config.arch }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=${{ matrix.config.arch }} cache-to: type=gha,mode=max,scope=${{ matrix.config.arch }} # Upload the tarball as an artifact - name: Upload image tarball uses: actions/upload-artifact@v4 with: name: image-${{ matrix.config.arch }} path: ${{ runner.temp }}/${{ matrix.config.arch }}.tar retention-days: 1 # Push to registries push-images: needs: build runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' }} steps: - name: Download all image tarballs uses: actions/download-artifact@v4 with: path: /tmp/images pattern: image-* merge-multiple: true - name: Docker Metadata action id: meta uses: docker/metadata-action@v5 with: images: | ${{ github.ref_type == 'tag' && format('{0}/{1}', secrets.DOCKERHUB_USERNAME, env.APP_NAME) || ''}} ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} tags: | type=schedule type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: ${{ env.ENABLE_DOCKERHUB == 1 }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GHCR if: ${{ env.ENABLE_GHCR == 1 }} uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Load images run: | docker load --input /tmp/images/amd64.tar docker load --input /tmp/images/arm64.tar - name: Create and push manifests run: | # Process each tag echo "${{ steps.meta.outputs.tags }}" | while read -r TAG; do # Skip empty lines [ -z "$TAG" ] && continue echo "Processing tag: $TAG" docker tag ${{ env.APP_NAME }}:${{ github.sha }}-amd64 $TAG-amd64 docker tag ${{ env.APP_NAME }}:${{ github.sha }}-arm64 $TAG-arm64 docker push $TAG-arm64 docker push $TAG-amd64 docker manifest create $TAG \ $TAG-amd64 \ $TAG-arm64 docker manifest push $TAG done # Update Docker Hub description update-description: needs: push-images runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Docker Hub Registry Description if: ${{ env.ENABLE_DOCKERHUB == 1 }} uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} short-description: | a web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. readme-filepath: ./README-DOCKER.md