-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update release-x-manual-helm-chart.yml
- Loading branch information
Showing
1 changed file
with
25 additions
and
95 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,36 @@ | ||
--- | ||
name: "release-X: Release helm chart" | ||
name: Release X: Helm Chart | ||
|
||
env: | ||
GIT_USERNAME: "DefectDojo release bot" | ||
GIT_EMAIL: "[email protected]" | ||
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 | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read # Чтение содержимого репозитория | ||
packages: write # Запись в пакетный реестр GitHub для публикации helm чарта | ||
|
||
jobs: | ||
release-chart: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
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/[email protected] | ||
# 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: Set up Helm | ||
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.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@8bf425b4d1344db7cd469a8d10a390876e0c77fd # v4.45.1 | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- 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: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
|
||
- name: Package Helm chart | ||
id: package-helm-chart | ||
- name: 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@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 | ||
helm package chart/ | ||
mv *.tgz helm-chart.tgz | ||
- name: Publish Helm Chart | ||
uses: octokit/[email protected] | ||
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 }} | ||
route: /repos/:owner/:repo/releases | ||
method: POST | ||
body: '{"tag_name": "v1.0.0", "target_commitish": "main", "name": "Release v1.0.0", "body": "Helm chart release."}' | ||
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 | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |