Skip to content

fix helm release

fix helm release #109

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
- develop
- 'feat-**'
jobs:
buildAndDeploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout & Build
uses: actions/checkout@v4
- name: Build
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: 'npm'
cache-dependency-path: package-lock.json
- run: npm ci && npm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Version
id: package-version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Build and push Docker Image
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
push: true
tags: >-
${{
github.ref == 'refs/heads/main' && format('gravitycloud/gravity-ci-cd-agent:latest,gravitycloud/gravity-ci-cd-agent:{0}', steps.package-version.outputs.VERSION) ||
github.ref == 'refs/heads/develop' && 'gravitycloud/gravity-ci-cd-agent:dev' ||
format('gravitycloud/gravity-ci-cd-agent:{0}', github.ref_name)
}}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Send Slack Notification
if: success()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "✅ Successfully deployed ${{ github.repository }} to Docker Hub\nBranch: ${{ github.ref_name }}\nTags: ${{
github.ref == 'refs/heads/main' && format('latest, {0}', steps.package-version.outputs.VERSION) ||
github.ref == 'refs/heads/develop' && 'dev' ||
github.ref_name
}}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
releaseHelmChart:
needs: buildAndDeploy
permissions:
contents: write # to push chart release and create a release (helm/chart-releaser-action)
packages: write # needed for ghcr access
id-token: write # needed for keyless signing
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Fetch history
run: git fetch --prune --unshallow
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.12.0
# Add step to package the chart
- name: Package Helm Chart
run: |
helm package chart/
- name: Push chart to GHCR
run: |
for pkg in *.tgz; do
helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts"
done
# see https://github.com/helm/chart-releaser/issues/183
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push charts to GHCR
run: |
shopt -s nullglob
for pkg in .cr-release-packages/*; do
if [ -z "${pkg:-}" ]; then
break
fi
helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts"
done