Skip to content

Commit

Permalink
Adding additional inputs for labeling resources in the composite CRIB…
Browse files Browse the repository at this point in the history
… GHA (#689)

* Adding additional inputs for labeling resources
  • Loading branch information
njegosrailic authored Nov 4, 2024
1 parent 5b5d034 commit e20e5fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sweet-tigers-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"crib-deploy-environment": major
---

Adding additional inputs for labeling resources in the composite CRIB GHA
28 changes: 27 additions & 1 deletion actions/crib-deploy-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ inputs:
default: "main"
required: false
description: Useful for testing updates in CRIB
chainlink-team:
default: ""
required: true
description: |
Specify a relevant value for tagging resources and attributing
costs to the correct team.
chainlink-product:
default: ""
required: true
description: |
Specify a relevant value for tagging resources and attributing
costs to the correct product.
outputs:
devspace-namespace:
description: "Kubernetes namespace used to provision a CRIB environment."
Expand Down Expand Up @@ -136,15 +148,28 @@ runs:
sanitized_branch=$(echo "${{ steps.generate-ns-name.outputs.branch-name }}" \
| sed 's/[^a-zA-Z0-9._-]/_/g' | cut -c1-63 | sed 's/[._-]$//')
# Validate that chainlink-team and chainlink-product inputs adhere to the Kubernetes label format.
if [[ ! "${{ inputs.chainlink-team }}" =~ ^[a-zA-Z0-9_.-]+$ ]] || [[ "${{ inputs.chainlink-team }}" -gt 63 ]] || [[ "${{ inputs.chainlink-team }}" =~ ^\. ]] || [[ "${{ inputs.chainlink-team }}" =~ \.$ ]]; then
echo "Invalid value for chainlink-team label: ${{ inputs.chainlink-team }}. Must be up to 63 characters, contain only letters, numbers, hyphens, underscores, and dots, and cannot start or end with a dot."
exit 1
fi
if [[ ! "${{ inputs.chainlink-product }}" =~ ^[a-zA-Z0-9_.-]+$ ]] || [[ "${{ inputs.chainlink-product }}" -gt 63 ]] || [[ "${{ inputs.chainlink-product }}" =~ ^\. ]] || [[ "${{ inputs.chainlink-product }}" =~ \.$ ]]; then
echo "Invalid value for chainlink-product label: ${{ inputs.chainlink-product }}. Must be up to 63 characters, contain only letters, numbers, hyphens, underscores, and dots, and cannot start or end with a dot."
exit 1
fi
NAMESPACE="${{ steps.generate-ns-name.outputs.devspace-namespace }}"
echo "Creating $NAMESPACE Kubernetes namespace.."
kubectl create ns "$NAMESPACE"
kubectl label namespace $NAMESPACE \
repo=${{ steps.generate-ns-name.outputs.repo-name }} \
branch="${sanitized_branch}" \
chain.link/product=${{ inputs.chainlink-product }} \
chain.link/team=${{ inputs.chainlink-team }} \
commit=${{ steps.generate-ns-name.outputs.commit-sha }} \
pr-number=${{ steps.generate-ns-name.outputs.pr-number || 'none' }} \
repo=${{ steps.generate-ns-name.outputs.repo-name }} \
workflow-job=${{ steps.generate-ns-name.outputs.workflow-job }} \
workflow-run-number=${{ steps.generate-ns-name.outputs.workflow-run-number }}
Expand Down Expand Up @@ -183,6 +208,7 @@ runs:
nix develop -c ./cribbit.sh "$DEVSPACE_NAMESPACE"
nix develop -c devspace run ${{ inputs.command }} ${{ inputs.command-args }}
- name: Render notification template
uses: actions/github-script@v7.0.1
id: render-slack-template
Expand Down

0 comments on commit e20e5fe

Please sign in to comment.