Skip to content

Commit

Permalink
Merge pull request #3 from cybozu-go/add-helm-ci
Browse files Browse the repository at this point in the history
add helm-related CI
  • Loading branch information
Hsn723 committed Jan 31, 2022
2 parents 54f1a64 + c7f273e commit 91b27c5
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/helm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release Charts

on:
push:
tags:
- 'chart-v*'

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.6.3

- name: Check chart version
run: |
tag_version=${GITHUB_REF##*/chart-v}
chart_version=$(cat charts/tenet/Chart.yaml | grep 'version:' | sed 's/version:\s//')
if [ "$tag_version" != "$chart_version" ]; then
echo "Different versions: tag \"$tag_version\", chart \"$chart_version\""
exit 1
fi
- name: Packaging the chart
run: helm package ./charts/tenet/

- uses: actions/upload-artifact@v2
with:
name: helm-charts
path: ./tenet-*.tgz
retention-days: 1

publish:
name: Publish charts on GitHub Pages
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v2
with:
ref: gh-pages

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.6.3

- uses: actions/download-artifact@v2
with:
name: helm-charts

- name: Update charts index
run: helm repo index --url https://cybozu-go.github.io/tenet/ --merge index.yaml .

- run: git add .

- name: Check diffs
run: |
diffs=$(git status -s)
if [ "$diffs" = "" ]; then
echo "NO_DIFF=1" >> $GITHUB_ENV
else
printf "%s\n" "$diffs"
fi
- name: Commit changes
if: env.NO_DIFF != '1'
run: |
git config --global user.name 'Cybozu Neco'
git config --global user.email 'cybozu-neco@users.noreply.github.com'
git commit -m 'update'
- name: Push to gh-pages
if: env.NO_DIFF != '1'
run: git push origin gh-pages
47 changes: 47 additions & 0 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Lint and Test Charts

on:
pull_request:
paths:
- "charts/**"
- '!**.md'

jobs:
lint-test:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 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: |
changed=$(ct list-changed --config ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml

- name: Create kind cluster
uses: helm/kind-action@v1.2.0
if: steps.list-changed.outputs.changed == 'true'
with:
node_image: kindest/node:v1.22.4

- name: Apply cert-manager
run: |
kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml
kubectl -n cert-manager wait --for=condition=available --timeout=180s --all deployments
- name: Run chart-testing (install)
run: ct install --config ct.yaml

0 comments on commit 91b27c5

Please sign in to comment.