From b6eaf6c457e34a034d9c5d13d5eca4e0ab26a0a2 Mon Sep 17 00:00:00 2001 From: Tommy Skaug Date: Tue, 12 Nov 2024 18:00:34 +0100 Subject: [PATCH] chore: update workflows --- .forgejo/workflows/release-charts.yaml | 62 +++++++++++++++++++++++++ .forgejo/workflows/validate-charts.yaml | 18 +++---- 2 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 .forgejo/workflows/release-charts.yaml diff --git a/.forgejo/workflows/release-charts.yaml b/.forgejo/workflows/release-charts.yaml new file mode 100644 index 0000000..f16db08 --- /dev/null +++ b/.forgejo/workflows/release-charts.yaml @@ -0,0 +1,62 @@ +name: Release Charts +on: + workflow_run: + workflows: [ "Validate Charts" ] + branches: [ main ] + types: + - completed + +jobs: + charts-changed: + name: Get Charts being Changed + runs-on: ci-os + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: List changed charts + id: changed-charts + run: | + changed=$(ct --config .forgejo/ct.yaml list-changed | tr '\n' ' ' | jq -R -s -c 'split(" ") | map(select(length > 0))') + if [[ -n "$changed" ]]; then + echo "changesExist=true" >> $GITHUB_ENV + echo "::set-output name=reposChanged::$changed" # Sets output as a JSON array + fi + outputs: + reposChanged: ${{ steps.changed-charts.outputs.reposChanged }} + changesExist: ${{ env.changesExist }} + + helm-publish: + name: "Publish Helm Chart" + needs: charts-changed + if: needs.charts-changed.outputs.changesExist == 'true' + runs-on: ci-os + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Publish + env: + FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + charts='${{ needs.charts-changed.outputs.reposChanged }}' + export REPO=${{ github.repository }} + export RELEASE_DIR=dist + export RELEASE_NOTES=/var/ci-os/templates/release-notes-template.md + export SHA=${{ github.sha }} + export FORGEJO_TOKEN="${{ secrets.GITHUB_TOKEN }}" + + for chart in $(echo $charts | jq -r '.[]'); do + rm -rf dist || true + mkdir dist || true + echo "packing $chart" + helm package "$chart" -d dist + CHART_NAME=$(yq -r .name "$chart/Chart.yaml") + CHART_VERSION=$(yq -r .version "$chart/Chart.yaml") + export TAG="$CHART_NAME-$CHART_VERSION" + echo "$TAG" + forgejo-release create + done diff --git a/.forgejo/workflows/validate-charts.yaml b/.forgejo/workflows/validate-charts.yaml index 0d5ff03..d735e6b 100644 --- a/.forgejo/workflows/validate-charts.yaml +++ b/.forgejo/workflows/validate-charts.yaml @@ -1,16 +1,18 @@ -name: Validate Chart +name: Validate Charts on: pull_request: paths: - 'charts/**' push: + branches: + - 'main' paths: - 'charts/**' jobs: charts-changed: name: Get Charts being Changed - runs-on: flakes-action + runs-on: ci-os steps: - name: Checkout uses: actions/checkout@v4 @@ -33,7 +35,7 @@ jobs: name: "Lint" needs: charts-changed if: needs.charts-changed.outputs.changesExist == 'true' - runs-on: flakes-action + runs-on: ci-os steps: - name: Checkout uses: actions/checkout@v4 @@ -51,7 +53,7 @@ jobs: name: "Audit" needs: charts-changed if: needs.charts-changed.outputs.changesExist == 'true' - runs-on: flakes-action + runs-on: ci-os steps: - name: Checkout uses: actions/checkout@v4 @@ -73,7 +75,7 @@ jobs: name: "Outdated APIs" needs: charts-changed if: needs.charts-changed.outputs.changesExist == 'true' - runs-on: flakes-action + runs-on: ci-os steps: - name: Checkout uses: actions/checkout@v4 @@ -86,9 +88,3 @@ jobs: echo "Checking deprecated apiVersions for $repo" helm template "$repo" -f "$repo/ci/pluto-values.yaml" | pluto detect - --ignore-deprecations done - #with: - # FORGEJO_API_URL=https://code.252.no/api/v1 - # FORGEJO_TOKEN=123 - # REPO_OWNER=tommy - # REPO_NAME=charts - # ISSUE_INDEX=115