Publish Docker images to docker hub when released (#13631)

(cherry picked from commit f937c511b1)
This commit is contained in:
kezhenxu94 2023-02-27 09:24:28 +08:00 committed by Jay Chung
parent 33f2cafdb0
commit d67f9bfd54
3 changed files with 96 additions and 8 deletions

View File

@ -20,9 +20,9 @@ on:
push: push:
branches: branches:
- dev - dev
release:
env: types:
HUB: ghcr.io/apache/dolphinscheduler - released
jobs: jobs:
build: build:
@ -41,12 +41,25 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-maven- ${{ 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 - name: Log in to the Container registry
uses: docker/login-action@v1.10.0 uses: docker/login-action@v2
with: with:
registry: ${{ env.HUB }} registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }} username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ env.DOCKER_PASSWORD }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx - name: Set up Docker Buildx

View File

@ -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 }}

View File

@ -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 issue template have **Version** selection bottom. So after we release DolphinScheduler we should and the new `<VERSION>` to
bug-report.yml 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 ### Send Announcement E-mail Community