From 6d7eb1c0e3e769f170f8c5f04b5fa7e4ef909266 Mon Sep 17 00:00:00 2001 From: Viren070 Date: Thu, 6 Feb 2025 12:05:21 +0000 Subject: [PATCH] feat(ci): GitHub Actions workflow for Docker image deployment --- .github/workflows/docker-deploy.yml | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docker-deploy.yml diff --git a/.github/workflows/docker-deploy.yml b/.github/workflows/docker-deploy.yml new file mode 100644 index 0000000..3855922 --- /dev/null +++ b/.github/workflows/docker-deploy.yml @@ -0,0 +1,63 @@ +name: Deploy Docker image to GitHub Container Registry and Docker Hub + +on: + push: + tags: + - 'v*' # Trigger on any tag that starts with 'v' + workflow_dispatch: + inputs: + tag: + description: 'Tag for the Docker image (e.g., v1.0.0)' + required: true + +jobs: + docker: + runs-on: ubuntu-latest + steps: + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Determine tag name + - name: Set tag name + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + else + echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV + fi + + # Set up QEMU for multi-platform builds + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + # Set up Docker Buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Log in to GitHub Container Registry (GHCR) + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Log in to Docker Hub + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Build and push Docker image to both GHCR and Docker Hub + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ secrets.GHCR_USERNAME }}/tmdb-addon:${{ env.TAG }} + ghcr.io/${{ secrets.GHCR_USERNAME }}/tmdb-addon:latest + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/tmdb-addon:${{ env.TAG }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/tmdb-addon:latest