Skip to content

Commit

Permalink
Publish Docker images to docker hub when released (#13631)
Browse files Browse the repository at this point in the history
(cherry picked from commit f937c51)
  • Loading branch information
kezhenxu94 authored and zhongjiajie committed Mar 30, 2023
1 parent 33f2caf commit d67f9bf
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 8 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ on:
push:
branches:
- dev

env:
HUB: ghcr.io/apache/dolphinscheduler
release:
types:
- released

jobs:
build:
Expand All @@ -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/login-action@v1.10.0
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
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/publish-helm-chart.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 7 additions & 1 deletion docs/docs/en/contribute/release/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d67f9bf

Please sign in to comment.