diff --git a/action.yaml b/action.yaml index bf1caed..97195cb 100644 --- a/action.yaml +++ b/action.yaml @@ -15,6 +15,7 @@ runs: run: ${{ gitea.action_path }}/k8sdeploy.sh env: ACTION_REPO: ${{ gitea.repository }} + ACTION_REF_NAME: ${{ gitea.ref_name }} ACTION_KUBECONFIG: ${{ inputs.kubeconfig }} ACTION_REGISTRY_USERNAME: ${{ inputs.registry_username }} ACTION_REGISTRY_PASSWORD: ${{ inputs.registry_password }} diff --git a/k8sdeploy.sh b/k8sdeploy.sh index 505b6f7..dab6232 100755 --- a/k8sdeploy.sh +++ b/k8sdeploy.sh @@ -6,7 +6,7 @@ set -a set +a REGISTRY="${IMAGEAPP%%/*}" -NS="${ACTION_REPO#*/}" +NS="${ACTION_REPO#*/}-${ACTION_REFNAME}" mkdir -p "$HOME/.kube/" echo "$ACTION_KUBECONFIG" > "$HOME/.kube/config" @@ -14,10 +14,11 @@ kubectl get namespace "$NS" || kubectl create namespace "$NS" kubectl config set-context --current --namespace="$NS" if [ -n "$ACTION_REGISTRY_PASSWORD" ]; then - kubectl create secret docker-registry regcred \ - --docker-server="$REGISTRY" \ - --docker-username="$ACTION_REGISTRY_USERNAME" \ - --docker-password="$ACTION_REGISTRY_PASSWORD" + kubectl get secret regcred \ + || kubectl create secret docker-registry regcred \ + --docker-server="$REGISTRY" \ + --docker-username="$ACTION_REGISTRY_USERNAME" \ + --docker-password="$ACTION_REGISTRY_PASSWORD" fi ./manifests/bin/devel.sh