Merge pull request #136 from meetwangdk/dk/tkp #14
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 工作流名称 | |
name: Build and Push Docker Image and Helm package | |
on: | |
push: | |
tags: "*" | |
env: | |
DOCKERHUB_REGISTRY: registry-1.docker.io | |
DOCKERHUB_REGISTRY_NAMESPACE: lunettes | |
DOCKERHUB_LUNETTES_REPO: lunettes/lunettes | |
DOCKERHUB_GRAFANA_REPO: lunettes/grafana | |
# Plugins to be installed. | |
GRAFANA_PLUGINS: "yesoreyeram-infinity-datasource,marcusolsson-json-datasource,marcusolsson-dynamictext-panel,volkovlabs-form-panel:3.1.0,volkovlabs-echarts-panel" | |
jobs: | |
main: | |
# Run on Ubuntu. | |
runs-on: ubuntu-latest | |
steps: | |
# git checkout code | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# Set up QEMU, as it is a dependency for docker buildx. | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
# Set up Docker buildx to facilitate the building of multi-platform images. | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
# 登录 docker hub | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
# GitHub Repo => Settings => Secrets add Docker Hub login key information | |
# DOCKERHUB_USERNAME is the Docker Hub username. | |
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security => New Access Token. | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Use the git command to retrieve the current tag information and store it in the environment variable APP_VERSION. | |
- name: Generate App Version | |
run: echo APP_VERSION=`git describe --tags --always` >> $GITHUB_ENV | |
- name: Build and push lunettes | |
id: docker_build_lunettes | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: build/docker/Dockerfile.lunettes | |
# Generate multi-platform images, see https://github.com/docker-library/bashbrew/blob/v0.1.1/architecture/oci-platform.go | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
# docker build arg | |
build-args: | | |
GOARCH=$(go env GOARCH) | |
# Generate two Docker tags: ${APP_VERSION} 和 latest | |
tags: | | |
${{ env.DOCKERHUB_LUNETTES_REPO }}:latest | |
${{ env.DOCKERHUB_LUNETTES_REPO }}:${{ env.APP_VERSION }} | |
- name: Build and push grafana | |
id: docker_build_grafana | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: build/docker/Dockerfile.grafana | |
# Generate multi-platform images, see https://github.com/docker-library/bashbrew/blob/v0.1.1/architecture/oci-platform.go | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
# docker build arg | |
build-args: | | |
PLUGINS=${{ env.GRAFANA_PLUGINS }} | |
# Generate two Docker tags: ${APP_VERSION} 和 latest | |
tags: | | |
${{ env.DOCKERHUB_GRAFANA_REPO }}:latest | |
${{ env.DOCKERHUB_GRAFANA_REPO }}:${{ env.APP_VERSION }} | |
- uses: azure/setup-helm@v3 | |
id: install | |
- name: get epository name | |
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV | |
- name: helm package chart | |
run: | | |
sed -i 's/grafanaImage: lunettes\/grafana:latest/grafanaImage: lunettes\/grafana:${{ env.APP_VERSION }}/g' deploy/helm/lunettes/values.yaml | |
sed -i 's/lunettesImage: lunettes\/lunettes:latest/lunettesImage: lunettes\/lunettes:${{ env.APP_VERSION }}/g' deploy/helm/lunettes/values.yaml | |
helm package deploy/helm/lunettes --app-version=${{ env.APP_VERSION }} --version=${{ env.APP_VERSION }} -d _out | |
- name: helm push chart | |
# OCI artifacts on Docker Hub | |
# see: https://docs.docker.com/docker-hub/oci-artifacts/ | |
run: | | |
helm push _out/lunettes-chart-${{ env.APP_VERSION }}.tgz oci://${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_REGISTRY_NAMESPACE }} |