diff --git a/.changeset/chilly-plants-try.md b/.changeset/chilly-plants-try.md new file mode 100644 index 00000000..68f1ad87 --- /dev/null +++ b/.changeset/chilly-plants-try.md @@ -0,0 +1,5 @@ +--- +"crib-deploy-environment": minor +--- + +update inputs to handle ns override diff --git a/actions/crib-deploy-environment/action.yml b/actions/crib-deploy-environment/action.yml index 90ca71b4..c9e07d14 100644 --- a/actions/crib-deploy-environment/action.yml +++ b/actions/crib-deploy-environment/action.yml @@ -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." @@ -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 }} @@ -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" @@ -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' }} \ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8d91413c..175883b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -169,6 +169,8 @@ importers: actions/ctf-show-grafana-in-test-summary: {} + actions/dependency-review: {} + actions/dispatch-workflow: {} actions/get-latest-github-release: {}