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

pipeline: create dev pipeline #46

Merged
merged 21 commits into from
Aug 5, 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
81 changes: 81 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build Charts

on:
pull_request:
paths:
- 'charts/**'

jobs:
create-matrix:
runs-on: ubuntu-latest

outputs:
charts: ${{ steps.charts.outputs.charts }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create changed charts matrix
id: charts
run: |
charts=$(git diff --merge-base origin/main --name-only | grep ^charts/ | cut -d/ -f2 | uniq | sort | jq -R -s -c 'split("\n")[:-1]')
echo "charts=${charts}"
echo "charts=${charts}" >> "$GITHUB_OUTPUT"

build-charts:
runs-on: ubuntu-latest
needs: create-matrix

strategy:
fail-fast: false
matrix:
chart: ${{ fromJSON(needs.create-matrix.outputs.charts) }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Run Helm dependency build
run: |
helm dependency build charts/${{ matrix.chart }}

- name: Run Helm template
run: |
helm template "${{ matrix.chart }}" charts/${{ matrix.chart }}

- name: Run Helm lint
run: |
helm lint charts/${{ matrix.chart }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Check for chart version change
run: |
old_version=$(git show origin/main:charts/${{ matrix.chart }}/Chart.yaml | yq eval ".version")
new_version=$(yq eval ".version" charts/${{ matrix.chart }}/Chart.yaml)
if [ "$old_version" == "$new_version" ]; then
echo "Chart version not changed"
exit 1
fi

- name: Push chart to GHCR
run: |
version=$(yq eval ".version" charts/${{ matrix.chart }}/Chart.yaml)
yq e -i '.version = "env(version)-${{ github.base_ref }}.${{ github.run_id }}"' charts/${{ matrix.chart }}/Chart.yaml
echo "Pushing chart ${{ matrix.chart }} with version $version-${{ github.head_ref }}.${GITHUB_SHA::7}"
helm push "${{ matrix.chart }}" "oci://ghcr.io/${{ github.repository }}"
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:

- name: Run chart-releaser
uses: helm/[email protected]
with:
skip_existing: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Expand Down