-
Notifications
You must be signed in to change notification settings - Fork 1.6k
108 lines (96 loc) · 3.74 KB
/
release-x-manual-helm-chart.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
99
100
101
102
103
104
105
106
107
108
---
name: "release-X: Release helm chart"
env:
GIT_USERNAME: "DefectDojo release bot"
GIT_EMAIL: "dojo-release-bot@users.noreply.github.com"
on:
workflow_dispatch:
inputs:
# the actual branch that can be chosen on the UI is made irrelevant by further steps
# because someone will forget one day to change it.
release_number:
type: string
description: 'Release number'
required: true
workflow_call:
inputs:
# the actual branch that can be chosen on the UI is made irrelevant by further steps
# because someone will forget one day to change it.
release_number:
type: string
description: 'Release number'
required: true
jobs:
release-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
# This action is deprecated. Not sure if it is even being used anymore...
# - name: Get upload URL
# id: get-upload-url
# uses: pdamianik/release-tag-to-upload-url-action@v1.0.1
# with:
# tag: ${{ github.event.inputs.release_number }}
# token: ${{ github.token }}
- name: Configure git
run: |
git config --global user.name "${{ env.GIT_USERNAME }}"
git config --global user.email "${{ env.GIT_EMAIL }}"
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.4.0
- name: Configure HELM repos
run: |-
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency list ./helm/defectdojo
helm dependency update ./helm/defectdojo
- name: Add yq
uses: mikefarah/yq@master
- name: Pin version docker version
id: pin_image
run: |-
yq --version
yq -i '.tag="${{ github.event.inputs.release_number }}"' helm/defectdojo/values.yaml
echo "Current image tag:`yq -r '.tag' helm/defectdojo/values.yaml`"
- name: Package Helm chart
id: package-helm-chart
run: |
mkdir build
helm package helm/defectdojo/ --destination ./build
echo "chart_version=$(ls build | cut -d '-' -f 2 | sed 's|\.tgz||')" >> $GITHUB_ENV
- name: Create release ${{ github.event.inputs.release_number }}
uses: softprops/action-gh-release@v2
with:
name: '${{ github.event.inputs.release_number }} 🌈'
tag_name: ${{ github.event.inputs.release_number }}
body: Run the release drafter to populate the release notes.
draft: true
prerelease: false
files: ./build/defectdojo-${{ env.chart_version }}.tgz
token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_REPOSITORY: DefectDojo/django-DefectDojo
- name: Update Helm repository index
id: update-helm-repository-index
run: |
git config --global user.name "${{ env.GIT_USERNAME }}"
git config --global user.email "${{ env.GIT_EMAIL }}"
git remote update
git fetch --all
git stash
git checkout helm-charts
git pull
if [ ! -f ./index.yaml ]; then
helm repo index ./build --url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/download/${{ github.event.inputs.release_number }}/"
else
helm repo index ./build --url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/download/${{ github.event.inputs.release_number }}/" --merge ./index.yaml
fi
cp -f ./build/index.yaml ./index.yaml
git add ./index.yaml
git commit -m "Update index.yaml"
git push -u origin helm-charts