This is an automated email from the ASF dual-hosted git repository.

zhongjiajie pushed a commit to branch 3.0.5-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git

commit d67f9bfd541f86aa14baa7a6c0dbf59253023584
Author: kezhenxu94 <[email protected]>
AuthorDate: Mon Feb 27 09:24:28 2023 +0800

    Publish Docker images to docker hub when released (#13631)
    
    (cherry picked from commit f937c511b127c4e6c61d0571c5cf20014726036e)
---
 .github/workflows/publish-docker.yaml      | 27 +++++++++---
 .github/workflows/publish-helm-chart.yaml  | 69 ++++++++++++++++++++++++++++++
 docs/docs/en/contribute/release/release.md |  8 +++-
 3 files changed, 96 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/publish-docker.yaml 
b/.github/workflows/publish-docker.yaml
index 0b7d6ff20c..802f048f70 100644
--- a/.github/workflows/publish-docker.yaml
+++ b/.github/workflows/publish-docker.yaml
@@ -20,9 +20,9 @@ on:
   push:
     branches:
       - dev
-
-env:
-  HUB: ghcr.io/apache/dolphinscheduler
+  release:
+    types:
+      - released
 
 jobs:
   build:
@@ -41,12 +41,25 @@ jobs:
           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
           restore-keys: |
             ${{ runner.os }}-maven-
+      - name: Set environment variables
+        run: |
+          if [[ ${{ github.event_name }} == "release" ]]; then
+            echo "DOCKER_REGISTRY=docker.io" >> $GITHUB_ENV
+            echo "DOCKER_USERNAME=${{ secrets.DOCKERHUB_USER }}" >> $GITHUB_ENV
+            echo "DOCKER_PASSWORD=${{ secrets.DOCKERHUB_TOKEN }}" >> 
$GITHUB_ENV
+            echo "HUB=apache" >> $GITHUB_ENV
+          else
+            echo "DOCKER_REGISTRY=ghcr.io/apache/dolphinscheduler" >> 
$GITHUB_ENV
+            echo "DOCKER_USERNAME=${{ github.actor }}" >> $GITHUB_ENV
+            echo "DOCKER_PASSWORD=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
+            echo "HUB=ghcr.io/apache/dolphinscheduler" >> $GITHUB_ENV
+          fi
       - name: Log in to the Container registry
-        uses: docker/[email protected]
+        uses: docker/login-action@v2
         with:
-          registry: ${{ env.HUB }}
-          username: ${{ github.actor }}
-          password: ${{ secrets.GITHUB_TOKEN }}
+          registry: ${{ env.DOCKER_REGISTRY }}
+          username: ${{ env.DOCKER_USERNAME }}
+          password: ${{ env.DOCKER_PASSWORD }}
       - name: Set up QEMU
         uses: docker/setup-qemu-action@v2
       - name: Set up Docker Buildx
diff --git a/.github/workflows/publish-helm-chart.yaml 
b/.github/workflows/publish-helm-chart.yaml
new file mode 100644
index 0000000000..e28b60e448
--- /dev/null
+++ b/.github/workflows/publish-helm-chart.yaml
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: publish-helm-chart
+
+on:
+  push:
+    branches:
+      - dev
+  release:
+    types:
+      - released
+
+env:
+  HUB: ghcr.io/apache/dolphinscheduler
+
+jobs:
+  build:
+    if: github.repository == 'apache/dolphinscheduler'
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    timeout-minutes: 30
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set environment variables
+        run: |
+          # TODO
+          if [[ ${{ github.event_name }} == "release" ]]; then
+            echo "HUB=registry-1.docker.io/apache" >> $GITHUB_ENV
+            echo "DOCKER_REGISTRY=docker.io" >> $GITHUB_ENV
+            echo "DOCKER_USERNAME=${{ secrets.DOCKERHUB_USER }}" >> $GITHUB_ENV
+            echo "DOCKER_PASSWORD=${{ secrets.DOCKERHUB_TOKEN }}" >> 
$GITHUB_ENV
+          else
+            echo "HUB=ghcr.io/apache/dolphinscheduler" >> $GITHUB_ENV
+            echo "DOCKER_REGISTRY=c" >> $GITHUB_ENV
+            echo "DOCKER_USERNAME=${{ github.actor }}" >> $GITHUB_ENV
+            echo "DOCKER_PASSWORD=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
+          fi
+      - name: Log in to the Container registry
+        uses: docker/login-action@v2
+        with:
+          registry: ${{ env.DOCKER_REGISTRY }}
+          username: ${{ env.DOCKER_USERNAME }}
+          password: ${{ env.DOCKER_PASSWORD }}
+      - name: Publish Helm Chart
+        working-directory: deploy/kubernetes
+        run: |
+          if [[ ${{ env.HUB }} == "ghcr.io/apache/dolphinscheduler" ]]; then
+            VERSION=0.0.0-$(git rev-parse --short HEAD)
+            sed -i "s/^version: .*/version: $VERSION/" 
dolphinscheduler/Chart.yaml
+          fi
+          helm dep up dolphinscheduler
+          helm package dolphinscheduler
+          helm push dolphinscheduler-helm-*.tgz oci://${{ env.HUB }}
diff --git a/docs/docs/en/contribute/release/release.md 
b/docs/docs/en/contribute/release/release.md
index 52e25ee940..17c6fa352b 100644
--- a/docs/docs/en/contribute/release/release.md
+++ b/docs/docs/en/contribute/release/release.md
@@ -497,7 +497,13 @@ the release version is `<VERSION>`, the following updates 
are required(note it w
     issue template have **Version** selection bottom. So after we release 
DolphinScheduler we should and the new `<VERSION>` to
     bug-report.yml
 
-### Find DolphinScheduler in [apache staging 
repositories](https://repository.apache.org/#stagingRepositories) and click 
`Release`
+### Publish Docker Image and Helm Chart
+
+We have a [workflow](../../../../.github/workflows/publish-docker.yaml) to 
automatically publish Docker images
+and a [workflow](../../../../.github/workflows/publish-helm-chart.yaml) to 
automatically publish Helm Chart to Docker Hub,
+after you change the release from "pre-release" to "release", the workflow 
will be triggered. All you need to do
+is to observe the aforementioned workflows, and after they are completed, you 
can pull the Docker images locally and
+verify that they work as expected.
 
 ### Send Announcement E-mail Community
 

Reply via email to