From d2cc1e6c6e41d628805f8444e452b7043ae14d81 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Tue, 7 Nov 2023 08:27:47 +0100 Subject: [PATCH 1/2] update pipeline --- .github/workflows/release.yml | 107 +++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 35 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82534be..9d91533 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,44 +2,81 @@ name: Release on: push: - # Sequence of patterns matched against refs/tags tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + - 'v*' + +permissions: + contents: write + packages: write + +env: + REGISTRY: ghcr.io + APP_NAME: ${{ github.repository }} jobs: build: - name: Upload Release Asset + name: Build runs-on: ubuntu-latest + steps: - - uses: actions/checkout@master - - uses: actions/setup-go@v2 - with: - go-version: '1.16' - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - - name: Build - run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=${{ steps.get_version.outputs.VERSION }}'" -o github-actions-exporter - - - name: Create Release - id: create_release - uses: actions/create-release@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: github-actions-exporter - asset_name: github-actions-exporter - asset_content_type: application/binary \ No newline at end of file + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + # go-version: 1.19 + go-version-file: go.mod + # The builtin cache feature ensures that installing golangci-lint + # is consistently fast. + cache: true + cache-dependency-path: go.sum + + - uses: nowsprinting/check-version-format-action@v3 + if: github.event_name != 'pull_request' + id: version + with: + prefix: 'v' + + - name: Build app + run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=${{ steps.version.outputs.full }}'" -o bin/${{ env.APP_NAME }} . + + - name: Generate MD5 + run: md5sum bin/${{ env.APP_NAME }} > bin/${{ env.APP_NAME }}.md5 + + - name: Push to release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + generate_release_notes: true + files: | + bin/${{ env.APP_NAME }} + bin/${{ env.APP_NAME }}.md5 + prerelease: ${{ steps.version.outputs.prerelease }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.APP_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + if: github.event_name != 'pull_request' + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From f5c14af604caff8066a1c746fda4a2e7f3586ee8 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Tue, 7 Nov 2023 08:28:05 +0100 Subject: [PATCH 2/2] remove helm chart (migrated to labbs/helm-charts --- .github/workflows/chart_release.yml | 19 ---- .../github-actions-exporter/.helmignore | 23 ----- .../github-actions-exporter/Chart.yaml | 14 --- .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 52 ----------- .../templates/deployment.yaml | 89 ------------------- .../templates/service.yaml | 17 ---- .../templates/serviceMonitor.yaml | 43 --------- .../github-actions-exporter/values.yaml | 77 ---------------- 9 files changed, 334 deletions(-) delete mode 100644 .github/workflows/chart_release.yml delete mode 100644 deploy/helm-chart/github-actions-exporter/.helmignore delete mode 100644 deploy/helm-chart/github-actions-exporter/Chart.yaml delete mode 100644 deploy/helm-chart/github-actions-exporter/templates/NOTES.txt delete mode 100644 deploy/helm-chart/github-actions-exporter/templates/_helpers.tpl delete mode 100644 deploy/helm-chart/github-actions-exporter/templates/deployment.yaml delete mode 100644 deploy/helm-chart/github-actions-exporter/templates/service.yaml delete mode 100644 deploy/helm-chart/github-actions-exporter/templates/serviceMonitor.yaml delete mode 100644 deploy/helm-chart/github-actions-exporter/values.yaml diff --git a/.github/workflows/chart_release.yml b/.github/workflows/chart_release.yml deleted file mode 100644 index a877089..0000000 --- a/.github/workflows/chart_release.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Release Chart -on: - push: - branches: - - master - paths: - - "deploy/helm-chart/**" - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Publish Helm charts - uses: stefanprodan/helm-gh-pages@master - with: - charts_dir: deploy/helm-chart - linting: off - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/deploy/helm-chart/github-actions-exporter/.helmignore b/deploy/helm-chart/github-actions-exporter/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/deploy/helm-chart/github-actions-exporter/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/deploy/helm-chart/github-actions-exporter/Chart.yaml b/deploy/helm-chart/github-actions-exporter/Chart.yaml deleted file mode 100644 index a1f87bb..0000000 --- a/deploy/helm-chart/github-actions-exporter/Chart.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v2 -name: github-actions-exporter -description: github-actions exporter for prometheus -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.4 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 1.8.1 diff --git a/deploy/helm-chart/github-actions-exporter/templates/NOTES.txt b/deploy/helm-chart/github-actions-exporter/templates/NOTES.txt deleted file mode 100644 index e69de29..0000000 diff --git a/deploy/helm-chart/github-actions-exporter/templates/_helpers.tpl b/deploy/helm-chart/github-actions-exporter/templates/_helpers.tpl deleted file mode 100644 index 1230151..0000000 --- a/deploy/helm-chart/github-actions-exporter/templates/_helpers.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "github-actions-exporter.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "github-actions-exporter.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "github-actions-exporter.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "github-actions-exporter.labels" -}} -helm.sh/chart: {{ include "github-actions-exporter.chart" . }} -{{ include "github-actions-exporter.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "github-actions-exporter.selectorLabels" -}} -app.kubernetes.io/name: {{ include "github-actions-exporter.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} diff --git a/deploy/helm-chart/github-actions-exporter/templates/deployment.yaml b/deploy/helm-chart/github-actions-exporter/templates/deployment.yaml deleted file mode 100644 index a1b7a62..0000000 --- a/deploy/helm-chart/github-actions-exporter/templates/deployment.yaml +++ /dev/null @@ -1,89 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "github-actions-exporter.fullname" . }} - labels: - {{ include "github-actions-exporter.labels" . | nindent 4 }} -spec: - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - {{ include "github-actions-exporter.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - app: {{ template "github-actions-exporter.name" . }} - release: {{ .Release.Name }} - {{ include "github-actions-exporter.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - env: - {{- range $name, $value := .Values.env }} - {{- if not (empty $value) }} - - name: {{ $name | quote }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - - name: GITHUB_TOKEN - valueFrom: - secretKeyRef: - name: {{ .Values.secret.name }} - key: github_token - optional: true - - name: GITHUB_APP_ID - valueFrom: - secretKeyRef: - name: {{ .Values.secret.name }} - key: github_app_id - optional: true - - name: GITHUB_APP_INSTALLATION_ID - valueFrom: - secretKeyRef: - name: {{ .Values.secret.name }} - key: github_app_installation_id - optional: true - - name: GITHUB_APP_PRIVATE_KEY - value: /etc/actions-exporter/github_app_private_key - volumeMounts: - - name: actions-exporter - mountPath: "/etc/actions-exporter" - readOnly: true - ports: - - name: http - containerPort: {{ .Values.env.PORT }} - protocol: TCP - resources: - {{- toYaml .Values.resources | nindent 12 }} - volumes: - - name: actions-exporter - secret: - secretName: {{ .Values.secret.name }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/deploy/helm-chart/github-actions-exporter/templates/service.yaml b/deploy/helm-chart/github-actions-exporter/templates/service.yaml deleted file mode 100644 index 84a58db..0000000 --- a/deploy/helm-chart/github-actions-exporter/templates/service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "github-actions-exporter.fullname" . }} - labels: - app: {{ template "github-actions-exporter.name" . }} - release: {{ .Release.Name }} - {{- include "github-actions-exporter.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.env.PORT }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "github-actions-exporter.selectorLabels" . | nindent 4 }} diff --git a/deploy/helm-chart/github-actions-exporter/templates/serviceMonitor.yaml b/deploy/helm-chart/github-actions-exporter/templates/serviceMonitor.yaml deleted file mode 100644 index 6edc6d7..0000000 --- a/deploy/helm-chart/github-actions-exporter/templates/serviceMonitor.yaml +++ /dev/null @@ -1,43 +0,0 @@ -{{- if $.Values.serviceMonitor }} -{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }} -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: -{{- if .Values.serviceMonitor.labels }} - labels: -{{ toYaml .Values.serviceMonitor.labels | indent 4}} -{{- end }} - name: {{ template "github-actions-exporter.fullname" . }} -{{- if .Values.serviceMonitor.namespace }} - namespace: {{ .Values.serviceMonitor.namespace }} -{{- end }} -spec: - endpoints: - - targetPort: {{ .Values.service.port }} -{{- if .Values.serviceMonitor.interval }} - interval: {{ .Values.serviceMonitor.interval }} -{{- end }} - path: /metrics -{{- if .Values.serviceMonitor.timeout }} - scrapeTimeout: {{ .Values.serviceMonitor.timeout }} -{{- end }} -{{- if .Values.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }} -{{- end }} - jobLabel: {{ template "github-actions-exporter.fullname" . }} - namespaceSelector: - matchNames: - - {{ .Release.Namespace }} - selector: - matchLabels: - app: {{ template "github-actions-exporter.name" . }} - release: {{ .Release.Name }} -{{- if .Values.serviceMonitor.targetLabels }} - targetLabels: -{{- range .Values.serviceMonitor.targetLabels }} - - {{ . }} -{{- end }} -{{- end }} -{{- end }} -{{- end }} diff --git a/deploy/helm-chart/github-actions-exporter/values.yaml b/deploy/helm-chart/github-actions-exporter/values.yaml deleted file mode 100644 index 4f2dcef..0000000 --- a/deploy/helm-chart/github-actions-exporter/values.yaml +++ /dev/null @@ -1,77 +0,0 @@ -# Default values for github-actions-exporter. - -image: - repository: spendeskplatform/github-actions-exporter - pullPolicy: IfNotPresent - tag: "v1.8.0" - -nameOverride: "" -fullnameOverride: "" - -env: - GITHUB_REFRESH: 30 # Refresh time Github Actions status in sec - GITHUB_ORGAS: "" # List all organisations you want get informations. ,, - GITHUB_REPOS: "" # List all repositories you want get informations. /,/,/ (like test/test) - PORT: 9999 # Exporter port - GITHUB_API_URL: api.github.com -# ENTERPRISE_NAME: "" # Needed for enterprise endpoints (/enterprises/{ENTERPRISE_NAME}/*) -# EXPORT_FIELDS: "repo,id,node_id,head_branch,head_sha,run_number,workflow_id,workflow,event,status" # A comma separated list of fields for workflow metrics that should be exported -# For the github authentications need to create a secret by default called actions-exporter -# for authentication via github personal token -# key: github_token -# for authentication via github app authentication -# key: github_app_id -# key: github_app_installation_id -# key: github_app_private_key -secret: - name: "actions-exporter" - -serviceMonitor: - enabled: yes - labels: - release: prometheus - # Set how frequently Prometheus should scrape - interval: 30s - # Set the namespace the ServiceMonitor should be deployed - # namespace: monitoring - # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator - # labels: - # Set timeout for scrape - # timeout: 10s - # Set of labels to transfer on the Kubernetes Service onto the target. - # targetLabels: [] - # metricRelabelings: [] - -imagePullSecrets: [] - -podAnnotations: {} - -podSecurityContext: {} -# fsGroup: 2000 - -securityContext: {} -# capabilities: -# drop: -# - ALL -# readOnlyRootFilesystem: true -# runAsNonRoot: true -# runAsUser: 1000 - -service: - type: ClusterIP - port: 9999 - - -resources: {} -# limits: -# cpu: 300m -# memory: 128Mi -# requests: -# cpu: 100m -# memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {}