remove custom branch and secrets, also rename some things
This commit is contained in:
@@ -3,36 +3,21 @@ name: Deploy
|
|||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
# Optional: Override the default k8s directory path
|
|
||||||
k8s_dir:
|
k8s_dir:
|
||||||
description: "Path to Kubernetes manifests directory"
|
description: "Override the default k8s directory path (k8s/)"
|
||||||
required: false
|
required: false
|
||||||
default: "k8s/"
|
default: "k8s/"
|
||||||
type: string
|
type: string
|
||||||
# Optional: Override the default helmfile path
|
|
||||||
helmfile_path:
|
helmfile_path:
|
||||||
description: "Path to helmfile.yaml"
|
description: "Override the default helmfile path (hemfile.yaml)"
|
||||||
required: false
|
required: false
|
||||||
default: "helmfile.yaml"
|
default: "helmfile.yaml"
|
||||||
type: string
|
type: string
|
||||||
# Optional: Skip Helm deployment even if helmfile exists
|
|
||||||
skip_helm_deployment:
|
skip_helm_deployment:
|
||||||
description: "Skip Helm deployment even if helmfile.yaml exists"
|
description: "Skip Helm deployment even if helmfile.yaml exists"
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
# Optional: Custom secrets to create (JSON array of secret objects)
|
|
||||||
custom_secrets:
|
|
||||||
description: "JSON array of secrets to create. Each secret should have: name, type, data"
|
|
||||||
required: false
|
|
||||||
default: "[]"
|
|
||||||
type: string
|
|
||||||
# Optional: Branch to deploy from
|
|
||||||
deploy_branch:
|
|
||||||
description: "Branch to deploy from"
|
|
||||||
required: false
|
|
||||||
default: "main"
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
detect-service-type:
|
detect-service-type:
|
||||||
@@ -69,8 +54,6 @@ jobs:
|
|||||||
if: needs.detect-service-type.outputs.has_k8s == 'true'
|
if: needs.detect-service-type.outputs.has_k8s == 'true'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
|
||||||
ref: ${{ inputs.deploy_branch }}
|
|
||||||
- uses: ./.gitea/actions/extract-namespace-from-repo-name
|
- uses: ./.gitea/actions/extract-namespace-from-repo-name
|
||||||
id: namespace
|
id: namespace
|
||||||
with:
|
with:
|
||||||
@@ -80,29 +63,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
method: kubeconfig
|
method: kubeconfig
|
||||||
kubeconfig: ${{ secrets.KUBECONFIG }}
|
kubeconfig: ${{ secrets.KUBECONFIG }}
|
||||||
- name: Create custom secrets
|
|
||||||
id: create-secrets
|
|
||||||
run: |
|
|
||||||
# Parse custom secrets from input
|
|
||||||
SECRETS='${{ inputs.custom_secrets }}'
|
|
||||||
if [ "$SECRETS" != "[]" ]; then
|
|
||||||
echo "Creating custom secrets..."
|
|
||||||
echo "$SECRETS" | jq -c '.[]' | while read -r secret; do
|
|
||||||
SECRET_NAME=$(echo "$secret" | jq -r '.name')
|
|
||||||
SECRET_TYPE=$(echo "$secret" | jq -r '.type // "generic"')
|
|
||||||
SECRET_DATA=$(echo "$secret" | jq -r '.data')
|
|
||||||
|
|
||||||
echo "Creating secret: $SECRET_NAME (type: $SECRET_TYPE)"
|
|
||||||
|
|
||||||
# Create the secret using kubectl
|
|
||||||
echo "$SECRET_DATA" | kubectl create secret $SECRET_TYPE $SECRET_NAME \
|
|
||||||
--from-literal=secret.json="$SECRET_DATA" \
|
|
||||||
--namespace=${{ steps.namespace.outputs.namespace }} \
|
|
||||||
--dry-run=client -o yaml | kubectl apply -f -
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No custom secrets to create"
|
|
||||||
fi
|
|
||||||
- name: Deploy Kubernetes manifests
|
- name: Deploy Kubernetes manifests
|
||||||
uses: azure/k8s-deploy@c7ebd0d5f39477a23f1b5dea0f52e6db04adf28e # v6.0.0
|
uses: azure/k8s-deploy@c7ebd0d5f39477a23f1b5dea0f52e6db04adf28e # v6.0.0
|
||||||
with:
|
with:
|
||||||
@@ -120,8 +80,6 @@ jobs:
|
|||||||
inputs.skip_helm_deployment != 'true'
|
inputs.skip_helm_deployment != 'true'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
|
||||||
ref: ${{ inputs.deploy_branch }}
|
|
||||||
- uses: ./.gitea/actions/extract-namespace-from-repo-name
|
- uses: ./.gitea/actions/extract-namespace-from-repo-name
|
||||||
id: namespace
|
id: namespace
|
||||||
with:
|
with:
|
||||||
@@ -132,29 +90,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
method: kubeconfig
|
method: kubeconfig
|
||||||
kubeconfig: ${{ secrets.KUBECONFIG }}
|
kubeconfig: ${{ secrets.KUBECONFIG }}
|
||||||
- name: Create custom secrets
|
|
||||||
id: create-secrets
|
|
||||||
run: |
|
|
||||||
# Parse custom secrets from input
|
|
||||||
SECRETS='${{ inputs.custom_secrets }}'
|
|
||||||
if [ "$SECRETS" != "[]" ]; then
|
|
||||||
echo "Creating custom secrets..."
|
|
||||||
echo "$SECRETS" | jq -c '.[]' | while read -r secret; do
|
|
||||||
SECRET_NAME=$(echo "$secret" | jq -r '.name')
|
|
||||||
SECRET_TYPE=$(echo "$secret" | jq -r '.type // "generic"')
|
|
||||||
SECRET_DATA=$(echo "$secret" | jq -r '.data')
|
|
||||||
|
|
||||||
echo "Creating secret: $SECRET_NAME (type: $SECRET_TYPE)"
|
|
||||||
|
|
||||||
# Create the secret using kubectl
|
|
||||||
echo "$SECRET_DATA" | kubectl create secret $SECRET_TYPE $SECRET_NAME \
|
|
||||||
--from-literal=secret.json="$SECRET_DATA" \
|
|
||||||
--namespace=${{ steps.namespace.outputs.namespace }} \
|
|
||||||
--dry-run=client -o yaml | kubectl apply -f -
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No custom secrets to create"
|
|
||||||
fi
|
|
||||||
- name: Deploy Helm
|
- name: Deploy Helm
|
||||||
uses: helmfile/helmfile-action@02671705b1dda1dc4b0a4ddd4f9f1ea8f4568c6f # v2.4.3
|
uses: helmfile/helmfile-action@02671705b1dda1dc4b0a4ddd4f9f1ea8f4568c6f # v2.4.3
|
||||||
with:
|
with:
|
||||||
@@ -163,7 +98,7 @@ jobs:
|
|||||||
# Summary job that always runs to show what was deployed
|
# Summary job that always runs to show what was deployed
|
||||||
deployment-summary:
|
deployment-summary:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [ detect-service-type, deploy-k8s, deploy-helm ]
|
needs: [detect-service-type, deploy-k8s, deploy-helm]
|
||||||
if: always()
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
- name: Deployment Summary
|
- name: Deployment Summary
|
||||||
@@ -187,11 +122,3 @@ jobs:
|
|||||||
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Service Type**: ${{ needs.detect-service-type.outputs.has_helmfile == 'true' && 'Helm + Kubernetes' || 'Kubernetes Only' }}" >> $GITHUB_STEP_SUMMARY
|
echo "**Service Type**: ${{ needs.detect-service-type.outputs.has_helmfile == 'true' && 'Helm + Kubernetes' || 'Kubernetes Only' }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Show custom secrets info
|
|
||||||
SECRETS='${{ inputs.custom_secrets }}'
|
|
||||||
if [ "$SECRETS" != "[]" ]; then
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "**Custom Secrets Created**: $(echo "$SECRETS" | jq length)" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "$SECRETS" | jq -r '.[] | "- " + .name + " (" + (.type // "generic") + ")"' >> $GITHUB_STEP_SUMMARY
|
|
||||||
fi
|
|
||||||
|
|||||||
Reference in New Issue
Block a user