ci: fix readme #4
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: Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.12.3 | |
- name: Login to GitHub Container Registry | |
uses: docker/#-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
cache: npm | |
- name: Install dependencies | |
run: npm install -g semantic-release @semantic-release/exec @semantic-release/github @semantic-release/npm | |
- name: Create package directory | |
run: mkdir -p charts/dist | |
- name: Run semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npx semantic-release | |
- name: Package Helm chart | |
if: ${{ env.RELEASE_VERSION != '' }} | |
run: mkdir -p charts/dist && helm package charts/kubanana -d ./charts/dist | |
- name: Set version from package.json | |
id: get_version | |
run: | | |
PKG_VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=v$PKG_VERSION" >> $GITHUB_OUTPUT | |
echo "VERSION_NO_V=$PKG_VERSION" >> $GITHUB_OUTPUT | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: build/Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}/controller:${{ steps.get_version.outputs.VERSION }} | |
ghcr.io/${{ github.repository }}/controller:latest | |
- name: Push Helm chart to GHCR | |
run: | | |
# Get packaged chart file | |
CHART_PACKAGE=$(ls ./charts/dist/kubanana-*.tgz | head -n 1) | |
# Push Helm chart to GHCR | |
helm push ${CHART_PACKAGE} oci://ghcr.io/${{ github.repository }}/charts | |
# Output success message | |
echo "Successfully pushed Helm chart to ghcr.io/${{ github.repository }}/charts" |