|
| 1 | +name: "Release helm chart" |
| 2 | + |
| 3 | +env: |
| 4 | + GIT_USERNAME: "DefectDojo release bot" |
| 5 | + |
| 6 | + workflow_name: 'release 2 tag release docker push' # needed in cache key, which doesn't support comma's |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + release-chart: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + ref: master |
| 18 | + fetch-depth: 0 |
| 19 | + - name: Configure git |
| 20 | + run: | |
| 21 | + git config --global user.name "${{ env.GIT_USERNAME }}" |
| 22 | + git config --global user.email "${{ env.GIT_EMAIL }}" |
| 23 | + - name: Install Helm |
| 24 | + uses: azure/setup-helm@v1 |
| 25 | + with: |
| 26 | + version: v3.4.0 |
| 27 | + - name: Configure HELM repos |
| 28 | + run: |- |
| 29 | + helm repo add stable https://charts.helm.sh/stable |
| 30 | + helm repo add bitnami https://charts.bitnami.com/bitnami |
| 31 | + helm dependency list ./helm/defectdojo |
| 32 | + helm dependency update ./helm/defectdojo |
| 33 | + - name: Package Helm chart |
| 34 | + id: package-helm-chart |
| 35 | + run: | |
| 36 | + mkdir build |
| 37 | + helm package helm/defectdojo/ --destination ./build |
| 38 | + echo "::set-output name=chart_version::$(ls build | cut -d '-' -f 2 | sed 's|\.tgz||')" |
| 39 | + - name: Upload Release Asset |
| 40 | + id: upload-release-asset |
| 41 | + uses: actions/upload-release-asset@v1 |
| 42 | + env: |
| 43 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + with: |
| 45 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 46 | + asset_path: ./build/defectdojo-${{ steps.package-helm-chart.outputs.chart_version }}.tgz |
| 47 | + asset_name: defectdojo-${{ steps.package-helm-chart.outputs.chart_version }}.tgz |
| 48 | + asset_content_type: application/tar+gzip |
| 49 | + - name: Update Helm repository index |
| 50 | + id: update-helm-repository-index |
| 51 | + run: | |
| 52 | + git config --global user.name "${{ env.GIT_USERNAME }}" |
| 53 | + git config --global user.email "${{ env.GIT_EMAIL }}" |
| 54 | + git remote update |
| 55 | + git fetch --all |
| 56 | + git checkout helm-charts |
| 57 | + git pull |
| 58 | + if [ ! -f ./index.yaml ]; then |
| 59 | + helm repo index ./build --url "${{ GITHUB_SERVER_URL }}/${{ GITHUB_REPOSITORY }}/releases/download/${{ github.event.inputs.release_number }}/" |
| 60 | + else |
| 61 | + helm repo index ./build --url "${{ GITHUB_SERVER_URL }}/${{ GITHUB_REPOSITORY }}/releases/download/${{ github.event.inputs.release_number }}/" --merge ./index.yaml |
| 62 | + fi |
| 63 | + cp -f ./build/index.yaml ./index.yaml |
| 64 | + git add ./index.yaml |
| 65 | + git commit -m "Update index.yaml" |
| 66 | + git push -u origin helm-charts |
0 commit comments