Add Helm pre-delete hook to remove configurations before Akri chart c… #1076
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Helm | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- .github/workflows/run-helm.yml | |
- deployment/** | |
- version.txt | |
pull_request: | |
branches: [ main ] | |
paths: | |
- .github/workflows/run-helm.yml | |
- deployment/** | |
- version.txt | |
release: | |
types: | |
- published | |
env: | |
helm_version: "3.2.1" | |
jobs: | |
lint-with-current-helm: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout the head commit of the branch | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- uses: azure/setup-helm@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Lint helm chart | |
run: | | |
helm lint deployment/helm --values test/helm-lint-values.yaml && echo "lint finished successfully" || echo ::warning::"lint found issues" | |
helm lint deployment/helm --values test/helm-lint-values-jobs.yaml && echo "lint with Job brokers finished successfully" || echo ::warning::"lint with Job brokers found issues" | |
helm: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout the head commit of the branch | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- uses: azure/setup-helm@v3 | |
with: | |
version: "v3.4.0" | |
# We should generate two sets of akri charts. | |
# One for our releases (akri) and one for our merged PRs (akri-dev). 'akri' should only be created for | |
# our releases and should default to not use dev containers. 'akri-dev' | |
# should build for any merged PR and should default to use our dev containers. | |
- name: When event_name == release, create akri chart | |
if: (github.event_name == 'release') | |
run: | | |
sed -i s/"name: akri"/"name: akri"/g ./deployment/helm/Chart.yaml | |
sed -i s/"description: A Helm chart for Akri"/"description: A Helm chart for Akri releases"/g ./deployment/helm/Chart.yaml | |
sed -i s/"useDevelopmentContainers: true"/"useDevelopmentContainers: false"/g ./deployment/helm/values.yaml | |
- name: When event_name != release, create akri-dev chart | |
if: (github.event_name != 'release') | |
run: | | |
sed -i s/"name: akri"/"name: akri-dev"/g ./deployment/helm/Chart.yaml | |
sed -i s/"description: A Helm chart for Akri"/"description: A Helm chart for Akri development"/g ./deployment/helm/Chart.yaml | |
sed -i s/"useDevelopmentContainers: true"/"useDevelopmentContainers: true"/g ./deployment/helm/values.yaml | |
- name: Lint helm chart | |
run: helm lint deployment/helm --values test/helm-lint-values.yaml && echo "lint finished successfully" || echo ::warning::"lint found issues" | |
- name: Ensure chart builds when setting expected values | |
run: helm template deployment/helm --values test/helm-lint-values.yaml | |
- name: Cache version.txt | |
run: | | |
mkdir -p /tmp/helm/repo | |
cp version.txt /tmp/helm/repo/version.txt | |
- name: Create new helm package | |
run: helm package --dependency-update --destination /tmp/helm/repo deployment/helm | |
- name: Inspect helm package | |
run: helm inspect all $(find /tmp/helm/repo -name "akri-*.tgz") | |
- name: Upload new helm package as artifact | |
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: charts | |
path: /tmp/helm/repo | |
- name: Checkout gh-pages | |
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
persist-credentials: false | |
- name: Get new chart from artifact path | |
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
shell: bash | |
run: | | |
mv /tmp/helm/repo/* . | |
find . | |
- name: Create new merged helm chart index | |
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
run: helm repo index --url https://project-akri.github.io/akri --merge index.yaml . | |
- name: Upload new merged helm chart index as artifact | |
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: index | |
path: index.yaml | |
- name: Create push with new akri chart for gh-pages | |
if: (github.event_name == 'release') | |
shell: bash | |
run: git add akri-$(cat version.txt).tgz | |
- name: Create push with new akri-dev chart for gh-pages | |
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
shell: bash | |
run: git add akri-dev-$(cat version.txt).tgz | |
- name: Push gh-pages | |
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main') | |
shell: bash | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git add index.yaml | |
git status | |
echo "Update Helm Repo for version $(cat version.txt)" | git commit --file - | |
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages |