Compare commits
1 Commits
feat-push-
...
feat-add-n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb9434e1e3 |
@@ -1,37 +0,0 @@
|
|||||||
# 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 }}
|
|
||||||
```
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
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"
|
|
||||||
20
.gitea/workflows/run_node.yaml
Normal file
20
.gitea/workflows/run_node.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Run NodeJS script with package cache
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
script:
|
||||||
|
description: Path to the Node.js script to run
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-node:
|
||||||
|
name: Run NodeJS script
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: ./.gitea/workflows/setup_node.yaml
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
- run: npm run ${{ inputs.script }}
|
||||||
33
.gitea/workflows/setup_node.yaml
Normal file
33
.gitea/workflows/setup_node.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: Setup NodeJS with package cache
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
node-version-file:
|
||||||
|
description: Path to the Node.js version file
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
default: .nvmrc
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
setup-node:
|
||||||
|
name: Setup NodeJS
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
id: cache-modules
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.npm
|
||||||
|
node_modules
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version-file: ${{ inputs.node-version-file }}
|
||||||
|
cache: "npm"
|
||||||
|
- if: steps.cache-modules.outputs.cache-hit != 'true'
|
||||||
|
run: npm ci
|
||||||
Reference in New Issue
Block a user