Skip to content

Commit

Permalink
feat: update crib deploy env - ns override (#911)
Browse files Browse the repository at this point in the history
* feat: crib deploy env - add ns-name-override

* chore: whoops

* chore: test

* chore: test

* chore: trigger test

* chore: cleanup

* chore: changeset / lint / review
  • Loading branch information
ajgrande924 authored Feb 28, 2025
1 parent 93585cc commit a53b2b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-plants-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"crib-deploy-environment": minor
---

update inputs to handle ns override
24 changes: 21 additions & 3 deletions actions/crib-deploy-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ inputs:
default: "crib-ci"
description: "Namespace name prefix for CRIB environment."
required: false
ns-name-override:
default: ""
description: "Namespace name override for CRIB environment."
required: false
command:
default: "core"
description: "The devspace command to run."
Expand Down Expand Up @@ -147,6 +151,7 @@ runs:
shell: bash
env:
NS_NAME_PREFIX: ${{ inputs.ns-name-prefix }}
NS_NAME_OVERRIDE: ${{ inputs.ns-name-override }}
PR_NUMBER: ${{ github.event.number }}
WORKFLOW_JOB: ${{ github.job }}
COMMIT_SHA: ${{ github.sha }}
Expand All @@ -155,7 +160,14 @@ runs:
REPO_NAME=$(basename "$GITHUB_REPOSITORY")
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
echo "devspace-namespace=${NS_NAME_PREFIX}-$(uuidgen | cut -c1-6)" | tee -a "$GITHUB_OUTPUT"
# configure namespace
if [ -z "$NS_NAME_OVERRIDE" ]; then
echo "devspace-namespace=${NS_NAME_PREFIX}-$(uuidgen | cut -c1-6)" | tee -a "$GITHUB_OUTPUT"
else
echo "devspace-namespace=${NS_NAME_OVERRIDE}" | tee -a "$GITHUB_OUTPUT"
fi
# configure rest of variables
echo "pr-number=${PR_NUMBER}" | tee -a "$GITHUB_OUTPUT"
echo "workflow-job=${WORKFLOW_JOB}" | tee -a "$GITHUB_OUTPUT"
echo "repo-name=${REPO_NAME}" | tee -a "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -256,10 +268,16 @@ runs:
exit 1
fi
overwrite=false
echo "Creating ${DEVSPACE_NAMESPACE} Kubernetes namespace.."
kubectl create ns "${DEVSPACE_NAMESPACE}"
if [ -z "$NS_NAME_OVERRIDE" ]; then
kubectl create ns "${DEVSPACE_NAMESPACE}"
else
overwrite=true
kubectl get ns "${DEVSPACE_NAMESPACE}" || kubectl create ns "${DEVSPACE_NAMESPACE}"
fi
kubectl label namespace ${DEVSPACE_NAMESPACE} \
kubectl label namespace --overwrite=$overwrite ${DEVSPACE_NAMESPACE} \
branch="${sanitized_branch}" \
commit=${{ steps.generate-ns-name.outputs.commit-sha }} \
pr-number=${{ steps.generate-ns-name.outputs.pr-number || 'none' }} \
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a53b2b0

Please sign in to comment.