Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ci): refactor helm GHA workflow #771

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/conventional-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ on:

jobs:
conventional_title:
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: true
uses: substra/substra-gha-workflows/.github/workflows/conventional-pr.yml@main
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


126 changes: 4 additions & 122 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,125 +17,7 @@ concurrency:
cancel-in-progress: true

jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: azure/[email protected]
with:
version: "v3.12.0"
id: install

- name: Install tools
run: |
sudo snap install yq

- name: Build dependencies
run: helm dep update charts/substra-backend

- name: Lint Chart
run: helm lint charts/substra-backend

- name: Validate version increment
run: |
helm repo add substra https://substra.github.io/charts

RES=$(helm search repo substra/substra-backend --version $(yq eval .version charts/substra-backend/Chart.yaml))

if [ "${RES}" == "No results found" ]; then
echo "Version incremented"
else
echo "Validation failed, you should upgrade the chart version in Chart.yaml"
exit 1
fi

generate-chart-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout bitnami-labs/readme-generator-for-helm
uses: actions/checkout@v4
with:
repository: "bitnami-labs/readme-generator-for-helm"
ref: "2.5.0"
path: readme-generator-for-helm

- name: Install readme-generator-for-helm dependencies
run: cd readme-generator-for-helm && npm install

- uses: actions/checkout@v4
with:
path: backend

- name: Execute readme-generator-for-helm
run: readme-generator-for-helm/bin/index.js -r backend/charts/substra-backend/README.md -v backend/charts/substra-backend/values.yaml

- name: Check diff
run: |
cd backend/
if [ -z "$(git status --porcelain)" ]; then
exit 0
else
echo "There should be no change generated, please run 'make doc' in backend/charts/ to update the chart README.md"
git diff
exit 1
fi

publish:
name: Publish
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs:
- test
- generate-chart-readme
steps:
- uses: actions/checkout@v4

- uses: azure/[email protected]
with:
version: "v3.12.0"
id: install

- run: sudo snap install yq

- name: Add dependencies repo
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add std-helm https://charts.helm.sh/stable
helm repo add twuni https://helm.twun.io

- name: Mark chart as prerelease
# This avoids the chart being tagged as latest release on artifacthub
# see https://artifacthub.io/docs/topics/annotations/helm/
run: |
CHART_YAML_LOCATION=charts/substra-backend/Chart.yaml
if [ $(yq '.version | contains("-")' $CHART_YAML_LOCATION) == 'true' ]
then
yq '.annotations."artifacthub.io/prerelease" = "true"' $CHART_YAML_LOCATION > .Chart.yaml.new
mv .Chart.yaml.new $CHART_YAML_LOCATION
fi

- name: Package chart
run: |
helm dep build charts/substra-backend
helm package charts/substra-backend

- name: Clone Substra charts
uses: actions/checkout@v4
with:
repository: Substra/charts
ref: "main"
token: ${{ secrets.CHARTS_GITHUB_TOKEN }}
path: substra-charts

- name: Publish chart
run: |
mv substra-backend-$(yq ".version" charts/substra-backend/Chart.yaml).tgz substra-charts/
cd substra-charts
helm repo index .
git add .
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git commit -s --message "GitHub Action: ${{ github.repository }}@${{ github.sha }}"
git push --quiet --set-upstream origin main
test-generate-publish:
uses: substra/substra-gha-workflows/.github/workflows/helm.yml@main
with:
helm-repositories: '[{"name": "bitnami", "url": "https://charts.bitnami.com/bitnami"},{"name": "std-helm", "url": "https://charts.helm.sh/stable"},{"name": "twumi", "url": "https://helm.twun.io"}]'
Loading