Skip to content

Commit 7f0a469

Browse files
authored
Merge pull request #372 from internxt/feat/add-publish-docker-image-action
[_]: feat/add-publish-docker-image-action
2 parents 76a950a + 1c9fa37 commit 7f0a469

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish Docker Image to Docker Hub
2+
on:
3+
release:
4+
types: [published]
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: 'Docker tag to publish (required). Must match vX.Y.Z'
9+
required: true
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set Docker tag
21+
run: |
22+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
23+
DOCKER_TAG="${{ github.event.inputs.tag }}"
24+
else
25+
DOCKER_TAG="${{ github.event.release.tag_name }}"
26+
fi
27+
28+
# Convert to lowercase and remove spaces
29+
DOCKER_TAG=$(echo "$DOCKER_TAG" | tr '[:upper:]' '[:lower:]' | tr -d ' ')
30+
31+
# Validate format (eg: v1.2.3)
32+
if [[ ! "$DOCKER_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
33+
echo "Error: Docker tag '$DOCKER_TAG' is invalid. Must match vX.Y.Z"
34+
exit 1
35+
fi
36+
37+
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
38+
echo "Docker tag will be: $DOCKER_TAG"
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Log in to Docker Hub
44+
uses: docker/login-action@v3
45+
with:
46+
username: ${{ secrets.DOCKERHUB_USERNAME }}
47+
password: ${{ secrets.DOCKERHUB_TOKEN }}
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: .
53+
file: ./Dockerfile
54+
push: true
55+
tags: |
56+
internxt/webdav:latest
57+
internxt/webdav:${{ env.DOCKER_TAG }}
58+
59+
- name: Update Docker Hub Description
60+
uses: peter-evans/dockerhub-description@v5
61+
with:
62+
username: ${{ secrets.DOCKERHUB_USERNAME }}
63+
password: ${{ secrets.DOCKERHUB_TOKEN }}
64+
repository: internxt/webdav
65+
short-description: Official WebDAV server for Internxt
66+
readme-filepath: ./docker/README.md
67+
enable-url-completion: true

0 commit comments

Comments
 (0)