Compare commits
1 Commits
0.1.5
...
feat-push-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
054a354666 |
37
.gitea/actions/helm-chart-push/README.md
Normal file
37
.gitea/actions/helm-chart-push/README.md
Normal 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 }}
|
||||||
|
```
|
||||||
96
.gitea/actions/helm-chart-push/action.yaml
Normal file
96
.gitea/actions/helm-chart-push/action.yaml
Normal 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"
|
||||||
Reference in New Issue
Block a user