1 Commits

Author SHA1 Message Date
Timo Behrendt
054a354666 feat: add helm-chart-push action 2025-08-18 08:55:00 +02:00
9 changed files with 135 additions and 113 deletions

View File

@@ -0,0 +1,37 @@
# helm-chart-push
A Gitea Action for pushing Helm charts to Gitea's built-in Helm registry. This action simplifies the process of publishing Helm charts to your Gitea instance's package registry.
## Usage
### Inputs
| Input | Required | Description | Default |
|-------|----------|-------------|---------|
| `registry-token` | true | The Bearer token for authenticating with the Gitea Helm Registry | - |
| `chart-path` | true | The local path to the Helm chart file (`.tgz` archive) | - |
| `repository-owner` | true | The owner/username of the Gitea Helm Repository | - |
| `gitea-base-url` | false | The base URL of your Gitea instance | `https://gitea.t000-n.de` |
### Basic Example
```yaml
name: Push Helm Chart
on:
push:
branches:
- main
jobs:
push-chart:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: helm package ./charts/my-chart
- name: Push to Gitea Registry
uses: ./.gitea/actions/helm-chart-push
with:
registry-token: ${{ secrets.GITEA_TOKEN }}
chart-path: ./my-chart-*.tgz
repository-owner: ${{ github.repository_owner }}
```

View File

@@ -0,0 +1,96 @@
name: Push Helm Chart
description: Push a Helm Chart to the Gitea Helm Repository
inputs:
registry-token:
description: The Bearer token for the Gitea Helm Registry
required: true
chart-path:
description: The path to the Helm Chart (e.g., ./my-chart-1.0.0.tgz)
required: true
repository-owner:
description: The owner of the Gitea Helm Repository
required: true
gitea-base-url:
description: The base URL of the Gitea instance (must include protocol)
required: false
default: "https://gitea.t000-n.de"
chart-name:
description: Optional name for the chart (used for logging and validation)
required: false
timeout:
description: Timeout for the HTTP request in seconds
required: false
default: "60"
runs:
using: "composite"
steps:
- name: Validate inputs
shell: bash
run: |
# Validate required inputs
if [[ -z "${{ inputs.registry-token }}" ]]; then
echo "Error: registry-token is required"
exit 1
fi
if [[ -z "${{ inputs.chart-path }}" ]]; then
echo "Error: chart-path is required"
exit 1
fi
if [[ -z "${{ inputs.repository-owner }}" ]]; then
echo "Error: repository-owner is required"
exit 1
fi
# Validate chart file exists
if [[ ! -f "${{ inputs.chart-path }}" ]]; then
echo "Error: Chart file not found at path: ${{ inputs.chart-path }}"
exit 1
fi
# Validate chart file is a valid tar.gz
if ! tar -tzf "${{ inputs.chart-path }}" >/dev/null 2>&1; then
echo "Error: Invalid chart file format. Must be a valid .tgz file"
exit 1
fi
# Validate Gitea base URL format
if [[ ! "${{ inputs.gitea-base-url }}" =~ ^https?:// ]]; then
echo "Error: gitea-base-url must include protocol (http:// or https://)"
exit 1
fi
echo "Input validation passed"
- name: Push Helm Chart
shell: bash
run: |
set -euo pipefail
# Set variables
CHART_PATH="${{ inputs.chart-path }}"
CHART_NAME="${inputs.chart-name:-$(basename "$CHART_PATH" .tgz)}"
TIMEOUT="${{ inputs.timeout }}"
echo "Pushing Helm chart: $CHART_NAME"
# Push chart with proper error handling
RESPONSE=$(curl --fail --show-error \
--silent \
--max-time "$TIMEOUT" \
--header "Authorization: Bearer ${{ inputs.registry-token }}" \
--header "Content-Type: application/gzip" \
--header "User-Agent: GitHub-Actions-Helm-Push/1.0" \
-X POST \
--upload-file "$CHART_PATH" \
"${{ inputs.gitea-base-url }}/api/packages/${{ inputs.repository-owner }}/helm/api/charts" \
2>&1) || {
echo "Failed to push Helm chart"
echo "Response: $RESPONSE"
exit 1
}
echo "Successfully pushed Helm chart: $CHART_NAME"

View File

@@ -1,24 +0,0 @@
name: CD
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Increment tag
id: tag
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@f377151b3a8843433cead1ca8a94936cdb848f11 # 0.1.27
with:
token: ${{ secrets.GITEA_TOKEN }}
- name: Push tag
uses: ./release-git-tag
with:
tag: ${{ steps.tag.outputs.new-tag }}

View File

@@ -1,8 +1,5 @@
# actions
Collection of Gitea friendly actions.
Collection of Gitea friendly actions & workflows.
## Actions
- [release-git-tag](./release-git-tag//README.md)
- [release-helm-chart](./release-helm-chart/README.md)
* [helm-chart-push](./.gitea/actions/helm-chart-push/README.md) Push a Helm Chart into the Gitea Helm Chart Registry

View File

@@ -1,9 +0,0 @@
# release-git-tag
Creates and pushes a Git tag to the remote repository.
```yaml
- uses: ./release-git-tag
with:
tag: v1.0.0
```

View File

@@ -1,15 +0,0 @@
name: Release Git tag
description: Releases a Git to origin
inputs:
tag:
description: The tag to release
required: true
runs:
using: "composite"
steps:
- shell: bash
run: |
git tag ${{ inputs.tag }}
git push origin ${{ inputs.tag }}

View File

@@ -1,23 +0,0 @@
# release-helm-chart
Packages and releases a Helm chart to a Gitea Helm registry.
## Inputs
| Input | Description | Required |
| ------------------- | ----------------------------- | -------- |
| `tag` | The version tag to release | Yes |
| `name` | The name of the Helm chart | Yes |
| `registry-user` | The username for the registry | Yes |
| `registry-password` | The password for the registry | Yes |
## Example
```yaml
- uses: ./release-helm-chart
with:
tag: v1.2.3
name: my-chart
registry-user: myuser
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
```

View File

@@ -1,30 +0,0 @@
name: Release Helm chart
description: Release the Helm chart
inputs:
tag:
description: The tag to release
required: true
name:
description: The name of the Helm chart
required: true
registry-user:
description: The username for the registry
required: true
registry-password:
description: The password for the registry
required: true
runs:
using: "composite"
steps:
- shell: bash
run: |
helm package ${{ inputs.name }} --version ${{ inputs.tag }}
- shell: bash
run: |
curl --verbose --fail --show-error \
--user ${{ inputs.registry-user }}:${{ inputs.registry-password }} \
-X POST \
--upload-file ./${{ inputs.name }}-${{ inputs.tag }}.tgz \
https://gitea.t000-n.de/api/packages/${{ inputs.registry-user }}/helm/api/charts

View File

@@ -1,7 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>t.behrendt/renovate-configs:common",
"local>t.behrendt/renovate-configs:action"
]
}