From b7253837428eecc0622ba194a78633ffb1ebdeb7 Mon Sep 17 00:00:00 2001 From: larry-internxt Date: Fri, 3 Oct 2025 11:39:54 +0200 Subject: [PATCH] feat: add GitHub Actions workflow to publish Docker image to Docker Hub --- .github/workflows/publish-docker-image.yml | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/publish-docker-image.yml diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml new file mode 100644 index 00000000..1e26ed78 --- /dev/null +++ b/.github/workflows/publish-docker-image.yml @@ -0,0 +1,67 @@ +name: Publish Docker Image to Docker Hub +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: 'Docker tag to publish (required). Must match vX.Y.Z' + required: true + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set Docker tag + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + DOCKER_TAG="${{ github.event.inputs.tag }}" + else + DOCKER_TAG="${{ github.event.release.tag_name }}" + fi + + # Convert to lowercase and remove spaces + DOCKER_TAG=$(echo "$DOCKER_TAG" | tr '[:upper:]' '[:lower:]' | tr -d ' ') + + # Validate format (eg: v1.2.3) + if [[ ! "$DOCKER_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Docker tag '$DOCKER_TAG' is invalid. Must match vX.Y.Z" + exit 1 + fi + + echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV + echo "Docker tag will be: $DOCKER_TAG" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: | + internxt/webdav:latest + internxt/webdav:${{ env.DOCKER_TAG }} + + - name: Update Docker Hub Description + uses: peter-evans/dockerhub-description@v5 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: internxt/webdav + short-description: Official WebDAV server for Internxt + readme-filepath: ./docker/README.md + enable-url-completion: true