-
Notifications
You must be signed in to change notification settings - Fork 37
98 lines (97 loc) · 4.81 KB
/
build-and-release-mixin.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: build-and-release-mixin
on:
#push:
# branches:
# - main
workflow_dispatch:
inputs:
mixinName:
description: 'Mixin name to build & release. Allowed mixins are "kubernetes", "node", "coredns" '
required: true
jobs:
build-and-release-mixin:
runs-on: ubuntu-latest
steps:
- name: Set-workflow-initiator
run: echo "Initiated by - ${GITHUB_ACTOR}"
- name: Set-User
run: echo "USER=$(echo ${GITHUB_ACTOR})" >> $GITHUB_ENV
- name: Set-branch-name-for-non-pr
if: ${{ github.event_name != 'pull_request' }}
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Set-branch-name-for-pr
if: ${{ github.event_name == 'pull_request' }}
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Set-Env
run: echo "ENV=dev" >> $GITHUB_ENV
- name: Set-date-time-in-PST
run: echo "DATE_TIME_PST=$(TZ=America/Los_Angeles date +%m-%d-%Y-%H-%M-%S)" >> $GITHUB_ENV
- name: Set-commit-sha
run: echo "COMMIT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
- name: get-go-version-greater-than-1-16
uses: actions/setup-go@v5
with:
go-version: '^1.17.3'
- name: Checkout-code
uses: actions/checkout@v4
- name: Set-HELM-Chart-Version
run: version=$(cat ./otelcollector/VERSION) && echo "HELM_CHART_VERSION=${version}" >> $GITHUB_ENV
- name: Set-semver
run: echo "SEMVER=${HELM_CHART_VERSION}-${BRANCH_NAME}-${DATE_TIME_PST}-${COMMIT_SHA}" >> $GITHUB_ENV
- name: Show-versions-On-build-machine
run: lsb_release -a && go version
#- name: Set-MixinName
# run: echo "MIXIN_NAME=coredns" >> $GITHUB_ENV
- name: Set-MixinName
run: echo "MIXIN_NAME=${{ github.event.inputs.mixinName }}" >> $GITHUB_ENV
- name: Get-Prereqs-To-Build-node-or-coredns-mixin
if: env.MIXIN_NAME != 'kubernetes'
# run: cd ./mixins/${{ env.MIXIN_NAME }}/ && go install github.com/google/go-jsonnet/cmd/jsonnet@latest && go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest && go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest && GO111MODULE=on go install -v github.com/prometheus/prometheus/cmd/promtool@main
run: cd ./mixins/${{ env.MIXIN_NAME }}/ && go install github.com/google/go-jsonnet/cmd/jsonnet@latest && go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest && go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
- name: Build-kubernetes-mixin
if: env.MIXIN_NAME == 'kubernetes'
run: cd ./mixins/${{ env.MIXIN_NAME }}/ && make all && zip ${{ env.MIXIN_NAME }}-mixins ./prometheus_alerts.yaml ./prometheus_rules.yaml ./dashboards_out/ -r
- name: Build-node-mixin
if: env.MIXIN_NAME == 'node'
run: cd ./mixins/${{ env.MIXIN_NAME }}/ && jb install && make all && zip ${{ env.MIXIN_NAME }}-mixins ./node_alerts.yaml ./node_rules.yaml ./dashboards_out/ -r
- name: Build-coredns-mixin
if: env.MIXIN_NAME == 'coredns'
run: cd ./mixins/${{ env.MIXIN_NAME }}/ && jb install && make notest && zip ${{ env.MIXIN_NAME }}-mixins ./prometheus_alerts.yaml ./prometheus_rules.yaml ./dashboards_out/ -r
- name: List-build-output
run: cd ./mixins/${{ env.MIXIN_NAME }}/ && ls -lt && ls -lt ./dashboards_out
#- name: Run-trivy-scanner-on-mixin
# uses: aquasecurity/trivy-action@master
# with:
# scan-type: 'fs'
# scan-ref: "./mixins/${{ env.MIXIN_NAME }}/"
# format: 'table'
# severity: 'CRITICAL,HIGH'
# exit-code: '1'
# timeout: '5m0s'
- name: Create-release
id: create-release
uses: actions/create-release@v1
if: github.event_name != 'pull_request' # && env.BRANCH_NAME == 'vishwa-dash'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.SEMVER }}
release_name: mixins-${{ env.MIXIN_NAME }}-release-${{ env.SEMVER }}
body: |
Release_Date : ${{ env.DATE_TIME_PST }}
Branch_Name : ${{ env.BRANCH_NAME }}
Released_By : ${{ env.USER }}
Mixin : ${{ env.MIXIN_NAME }}
draft: false
prerelease: true
- name: Upload-Release-Asset
id: upload-Release-Asset
uses: actions/upload-release-asset@v1
if: github.event_name != 'pull_request' # && env.BRANCH_NAME == 'vishwa-dash'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: "./mixins/${{ env.MIXIN_NAME }}/${{ env.MIXIN_NAME }}-mixins.zip"
asset_name: "${{ env.MIXIN_NAME }}-mixins.zip"
asset_content_type: application/zip