add helm package #1
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: | ||
LUNETTES_DOCKERHUB_REPO: lunettes/lunettes | ||
GRAFANA_DOCKERHUB_REPO: lunettes/grafana | ||
# Plugins to be installed. | ||
GRAFANA_PLUGINS: yesoreyeram-infinity-datasource marcusolsson-json-datasource volkovlabs-form-panel marcusolsson-dynamictext-panel | ||
REGISTRY: ghcr.io | ||
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 | ||
# Generate two Docker tags: ${APP_VERSION} 和 latest | ||
tags: | | ||
${{ env.LUNETTES_DOCKERHUB_REPO }}:latest | ||
${{ env.LUNETTES_DOCKERHUB_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 | ||
# docker build arg | ||
build-args: | | ||
PLUGINS=${{ env.GRAFANA_PLUGINS }} | ||
# Generate two Docker tags: ${APP_VERSION} 和 latest | ||
tags: | | ||
${{ env.GRAFANA_DOCKERHUB_REPO }}:latest | ||
${{ env.GRAFANA_DOCKERHUB_REPO }}:${{ env.APP_VERSION }} | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
# Publishing and installing a package with GitHub Actions | ||
# see: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- 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 | ||
run: helm push _out/lunettes-chart-${{ env.APP_VERSION }}.tgz oci://ghcr.io/${{ env.REPOSITORY_NAME }} |