Consolidated actions and variables
This commit is contained in:
27
slug/action.yml
Normal file
27
slug/action.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Compute Preview Slug
|
||||
description: Derive a URL-safe slug and deterministic port from a branch name
|
||||
|
||||
inputs:
|
||||
branch:
|
||||
required: true
|
||||
description: Branch name to slugify
|
||||
|
||||
outputs:
|
||||
slug:
|
||||
description: URL-safe branch slug
|
||||
value: ${{ steps.compute.outputs.slug }}
|
||||
port:
|
||||
description: Deterministic port derived from the slug
|
||||
value: ${{ steps.compute.outputs.port }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Compute slug and port
|
||||
id: compute
|
||||
shell: bash
|
||||
run: |
|
||||
SLUG=$(echo "${{ inputs.branch }}" | tr '/' '-' | tr '_' '-' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | cut -c1-40)
|
||||
echo "slug=$SLUG" >> "$GITHUB_OUTPUT"
|
||||
PORT=$(( 20000 + ( $(echo -n "$SLUG" | cksum | awk '{print $1}') % 10000 ) ))
|
||||
echo "port=$PORT" >> "$GITHUB_OUTPUT"
|
||||
Reference in New Issue
Block a user