|
| 1 | +name: Lint/Builds/Push Helm charts to Github Registry |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - 'toggle/**' |
| 10 | + |
| 11 | +permissions: |
| 12 | + packages: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Publish Helm |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + - chart: react-serve |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Install Helm |
| 28 | + uses: azure/setup-helm@v3 |
| 29 | + |
| 30 | + # Lint/Build |
| 31 | + - name: Helm dependency |
| 32 | + working-directory: ./toggle/${{ matrix.chart }} |
| 33 | + run: | |
| 34 | + yq --indent 0 '.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' ./Chart.lock | sh -- |
| 35 | + helm dependency build ./ |
| 36 | +
|
| 37 | + - name: 🐳 Helm lint |
| 38 | + working-directory: ./toggle/${{ matrix.chart }} |
| 39 | + run: helm lint ./ --values ./values-test.yaml |
| 40 | + |
| 41 | + - name: 🐳 Helm template |
| 42 | + working-directory: ./toggle/${{ matrix.chart }} |
| 43 | + run: helm template ./ --values ./values-test.yaml |
| 44 | + |
| 45 | + # Publish |
| 46 | + - name: Login to GitHub Container Registry |
| 47 | + uses: docker/login-action@v3 |
| 48 | + if: ${{ github.event_name == 'push' }} |
| 49 | + with: |
| 50 | + registry: ghcr.io |
| 51 | + username: ${{ github.actor }} |
| 52 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Package Helm Chart |
| 55 | + working-directory: ./toggle/${{ matrix.chart }} |
| 56 | + if: ${{ github.event_name == 'push' }} |
| 57 | + run: | |
| 58 | + helm package ./ -d .helm-charts |
| 59 | +
|
| 60 | + - name: Push Helm Chart |
| 61 | + working-directory: ./toggle/${{ matrix.chart }} |
| 62 | + if: ${{ github.event_name == 'push' }} |
| 63 | + env: |
| 64 | + OCI_REPO: oci://ghcr.io/${{ github.repository }} |
| 65 | + run: | |
| 66 | + OCI_REPO=$(echo $OCI_REPO | tr '[:upper:]' '[:lower:]') |
| 67 | + PACKAGE_FILE=$(ls .helm-charts/*.tgz | head -n 1) |
| 68 | + echo "## Helm Chart" >> $GITHUB_STEP_SUMMARY |
| 69 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 70 | + echo "Helm push output:" >> $GITHUB_STEP_SUMMARY |
| 71 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 72 | + echo '```bash' >> $GITHUB_STEP_SUMMARY |
| 73 | + helm push "$PACKAGE_FILE" $OCI_REPO >> $GITHUB_STEP_SUMMARY |
| 74 | + echo '```' >> $GITHUB_STEP_SUMMARY |
0 commit comments