From a05b836cd1124d6f7aa225d194f115f85daa7275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=97=AA=D1=94=CE=BD=CE=B9=CE=B7=20=E1=97=B7=CF=85=D0=BD?= =?UTF-8?q?=CA=9F?= Date: Tue, 24 Nov 2020 08:30:11 -0500 Subject: [PATCH] [workflow] update linting and release workflows (#195) --- ct.yaml => .github/ct.yaml | 6 ++-- .github/workflows/lint-test.yaml | 47 +++++++++++++++++-------- .github/workflows/release.yaml | 59 +++++++++++++++++++++++--------- 3 files changed, 78 insertions(+), 34 deletions(-) rename ct.yaml => .github/ct.yaml (83%) diff --git a/ct.yaml b/.github/ct.yaml similarity index 83% rename from ct.yaml rename to .github/ct.yaml index d3eaec43..e261d52b 100644 --- a/ct.yaml +++ b/.github/ct.yaml @@ -1,8 +1,10 @@ +remote: origin +target-branch: master helm-extra-args: --timeout 600s chart-dirs: - charts +excluded-charts: + - common chart-repos: - bitnami=https://charts.bitnami.com/bitnami - k8s-at-home=https://k8s-at-home.com/charts -excluded-charts: - - common diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index f6b0a358..43216ce2 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -1,28 +1,45 @@ name: Lint and Test Charts + on: pull_request + jobs: lint-test: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - - name: Fetch history + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.0.1 + + - name: Run chart-testing (list-changed) + id: list-changed run: | - git fetch --prune --unshallow; - echo "commitmsg=$(git log --format=%B -n 1 ${{ github.event.after }})" >> $GITHUB_ENV + changed=$(ct list-changed --config .github/ct.yaml) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi + - name: Run chart-testing (lint) id: lint - uses: helm/chart-testing-action@v1.0.0 - if: "! contains(env.commitmsg, '[skip lint]')" - with: - command: lint - config: ct.yaml + run: ct lint --config .github/ct.yaml + if: steps.list-changed.outputs.changed == 'true' + - name: Create kind cluster - uses: helm/kind-action@v1.0.0 - if: "steps.lint.outputs.changed == 'true' && ! contains(env.commitmsg, '[skip install]')" + uses: helm/kind-action@v1.1.0 + if: steps.list-changed.outputs.changed == 'true' + - name: Run chart-testing (install) - uses: helm/chart-testing-action@v1.0.0 - if: "steps.lint.outputs.changed == 'true' && ! contains(env.commitmsg, '[skip install]')" - with: - command: install - config: ct.yaml + run: ct install --config .github/ct.yaml + if: steps.list-changed.outputs.changed == 'true' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7bd25aa8..77951ce9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,10 +1,11 @@ - name: Release Charts on: push: branches: - master + paths: + - "charts/**" jobs: release: @@ -13,6 +14,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Turnstyle uses: softprops/turnstyle@v1 @@ -21,25 +24,47 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Fetch history - run: git fetch --prune --unshallow + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.1.0 + with: + charts_repo_url: https://k8s-at-home.com/charts/ + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + # Update the generated timestamp in the index.yaml + # needed until https://github.com/helm/chart-releaser/issues/90 + # or helm/chart-releaser-action supports this + post-release: + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: "gh-pages" + fetch-depth: 0 - name: Configure Git run: | git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - # See https://github.com/helm/chart-releaser-action/issues/6 - - name: Install Helm + + - name: Commit and push timestamp updates run: | - curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 - chmod 700 get_helm.sh - ./get_helm.sh - - name: Add dependency chart repos - run: | - helm repo add stable https://charts.helm.sh/stable - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.0.0 - with: - charts_repo_url: https://k8s-at-home.com/charts/ - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if [[ -f index.yaml ]]; then + export generated_date=$(date --utc +%FT%T.%9NZ) + sed -i -e "s/^generated:.*/generated: \"$generated_date\"/" index.yaml + git add index.yaml + git commit -sm "Update generated timestamp [ci-skip]" || exit 0 + git push + fi