chore: Grafana Helm charts and build process into GitHub actions (#125) #15
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
# This workflow will build a docker container, publish it to Google Container Registry, and deploy it to GKE when there is a push to the "master" branch. | |
# | |
# To configure this workflow: | |
# | |
# 1. Ensure that your repository contains the necessary configuration for your Google Kubernetes Engine cluster, including deployment.yml, kustomization.yml, service.yml, etc. | |
# | |
# 2. Create and configure a Workload Identity Provider for GitHub (https://github.com/google-github-actions/auth#setting-up-workload-identity-federation) | |
# | |
# 3. Change the values for the GAR_LOCATION, GKE_ZONE, GKE_CLUSTER, IMAGE, REPOSITORY and DEPLOYMENT_NAME environment variables (below). | |
# | |
# For more support on how to run the workflow, please visit https://github.com/google-github-actions/setup-gcloud/tree/master/example-workflows/gke-kustomize | |
name: Release(tag), Build and push to GCP registry | |
on: | |
push: | |
branches: [ "split", "master" ] | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
GAR_LOCATION: asia-northeast1 # TODO: update region of the Artifact Registry | |
IMAGE: shibuya | |
jobs: | |
release-please: | |
name: release-please | |
runs-on: ubuntu-20.04 | |
outputs: | |
tag_name: ${{ steps.create_release.outputs.tag_name }} | |
steps: | |
- uses: googleapis/release-please-action@v4 | |
id: create_release | |
with: | |
# this assumes that you have created a personal access token | |
# (PAT) and configured it as a GitHub action secret named | |
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important). | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# this is a built-in strategy in release-please, see "Action Inputs" | |
# for more options | |
release-type: simple | |
setup-build-publish-push: | |
needs: release-please | |
name: Setup, Build, push | |
runs-on: ubuntu-20.04 | |
environment: production | |
if: ${{ needs.release-please.outputs.tag_name != '' }} | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.19' | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
token_format: 'access_token' | |
- name: Docker configuration | |
run: |- | |
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: "v3.13.3" | |
- name: build app chart | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
cd shibuya | |
make helm_charts | |
sh ../helm_utils/chart_releaser.sh install/shibuya | |
- name: build metrics dashboard chart | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
cd grafana | |
helm package metrics-dashboard | |
sh ../helm_utils/chart_releaser.sh metrics-dashboard | |
- name: build metrics dashboard image | |
env: | |
tag_name: ${{ needs.release-please.outputs.tag_name }} | |
run: |- | |
cd grafana && make metrics_dashboard_image | |
# Build the Docker image | |
- name: Build api | |
env: | |
tag_name: ${{ needs.release-please.outputs.tag_name }} | |
run: |- | |
cd shibuya && make api_image component=api | |
- name: Build controller | |
env: | |
tag_name: ${{ needs.release-please.outputs.tag_name }} | |
run: |- | |
cd shibuya && make controller_image component=controller | |
- name: build jmeter agent | |
env: | |
tag_name: ${{ needs.release-please.outputs.tag_name }} | |
# we specify the jmeter version we are using in the component name | |
# So we can cleary know which jmeter version we are using | |
run: |- | |
cd shibuya && make jmeter_agent_image component=jmeter-3.3 | |