Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ab54b15dd | |||
| a19a1f9a8e | |||
| 178987a0f1 |
43
README.md
43
README.md
@@ -11,7 +11,6 @@ Table of Contents
|
|||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Deploy](#deploy)
|
- [Deploy](#deploy)
|
||||||
- [Slug](#slug)
|
|
||||||
- [Cleanup](#cleanup)
|
- [Cleanup](#cleanup)
|
||||||
- [Roadmap](#roadmap)
|
- [Roadmap](#roadmap)
|
||||||
|
|
||||||
@@ -72,65 +71,47 @@ See `examples/deploy.yml` for a complete workflow covering production, preview,
|
|||||||
|
|
||||||
### Deploy
|
### Deploy
|
||||||
|
|
||||||
Builds the Docker image, starts the container, and registers a Pangolin resource.
|
Builds the Docker image, starts the container, and registers a Pangolin resource. The branch name drives everything else: pushes to the repo's default branch deploy as `production`, all other branches deploy as previews with a slugified tag, a deterministic host port, and a `${slug}.${app-name}` subdomain.
|
||||||
|
|
||||||
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/deploy@v1
|
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/deploy@v1
|
||||||
with:
|
with:
|
||||||
app-name: my-app
|
app-name: my-app
|
||||||
tag: production
|
branch: ${{ github.ref_name }}
|
||||||
port: "3001"
|
|
||||||
environment: production
|
|
||||||
subdomain: my-app
|
|
||||||
|
|
||||||
Inputs
|
Inputs
|
||||||
|
|
||||||
`app-name`
|
`app-name`
|
||||||
|
|
||||||
Application name (used for image/container naming)
|
Application name (used for image/container naming, and as the production subdomain)
|
||||||
|
|
||||||
`tag`
|
`branch`
|
||||||
|
|
||||||
Image/container tag (e.g. `production` or a branch slug)
|
Branch name. Matches against `github.event.repository.default_branch` to decide production vs. preview. `refs/heads/` prefix is stripped.
|
||||||
|
|
||||||
`port`
|
|
||||||
|
|
||||||
Host port to expose
|
|
||||||
|
|
||||||
`internal-port`
|
`internal-port`
|
||||||
|
|
||||||
Port the app listens on inside the container (default `3000`)
|
Port the app listens on inside the container (default `3000`)
|
||||||
|
|
||||||
`environment`
|
|
||||||
|
|
||||||
`production` or `preview`
|
|
||||||
|
|
||||||
`subdomain`
|
|
||||||
|
|
||||||
Subdomain for the Pangolin resource
|
|
||||||
|
|
||||||
`build-args`
|
`build-args`
|
||||||
|
|
||||||
Extra `KEY=VALUE` docker build args (space-separated)
|
Extra `KEY=VALUE` docker build args (space-separated)
|
||||||
|
|
||||||
### Slug
|
`env-vars`
|
||||||
|
|
||||||
Derives a URL-safe slug and a deterministic port from a branch name. Strips `refs/heads/` so either `github.ref_name` or `github.event.ref` works.
|
Runtime env vars for the container, one `KEY=VALUE` per line. Merged on top of `/opt/apps/${app-name}/.env.${environment}` on the runner — keys defined here win. Reference secrets here so values stay masked in logs.
|
||||||
|
|
||||||
- id: slug
|
env-vars: |
|
||||||
uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/slug@v1
|
DATABASE_URL=${{ secrets.DATABASE_URL }}
|
||||||
with:
|
API_KEY=${{ secrets.API_KEY }}
|
||||||
branch: ${{ github.ref_name }}
|
|
||||||
|
|
||||||
Outputs: `slug`, `port`.
|
|
||||||
|
|
||||||
### Cleanup
|
### Cleanup
|
||||||
|
|
||||||
Stops the preview container and removes its Pangolin resource. Intended for `delete` branch events.
|
Stops the preview container and removes its Pangolin resource. Intended for `delete` branch events — the slug is derived from the branch name internally.
|
||||||
|
|
||||||
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/cleanup@v1
|
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/cleanup@v1
|
||||||
with:
|
with:
|
||||||
app-name: my-app
|
app-name: my-app
|
||||||
slug: ${{ steps.slug.outputs.slug }}
|
branch: ${{ github.event.ref }}
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,41 @@
|
|||||||
name: Cleanup Preview
|
name: Cleanup Preview
|
||||||
description: Stop container and remove Pangolin resource
|
description: Stop container and remove Pangolin resource for a deleted branch
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
app-name:
|
app-name:
|
||||||
required: true
|
required: true
|
||||||
description: Application name (used for image/container naming)
|
description: Application name (used for image/container naming)
|
||||||
slug:
|
branch:
|
||||||
required: true
|
required: true
|
||||||
description: Branch slug to clean up
|
description: Branch name being cleaned up
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
- name: Derive cleanup parameters
|
||||||
|
id: derive
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
BRANCH: ${{ inputs.branch }}
|
||||||
|
run: |
|
||||||
|
BRANCH="${BRANCH#refs/heads/}"
|
||||||
|
SLUG=$(echo "$BRANCH" | tr '/_' '--' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | cut -c1-40)
|
||||||
|
REPO_SLUG="${GITHUB_REPOSITORY//\//-}"
|
||||||
|
{
|
||||||
|
echo "slug=$SLUG"
|
||||||
|
echo "resource-name=${REPO_SLUG}-${SLUG}"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Remove Pangolin resource
|
- name: Remove Pangolin resource
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
bash ${{ github.action_path }}/pangolin-delete.sh \
|
bash ${{ github.action_path }}/pangolin-delete.sh \
|
||||||
--resource-name "${{ inputs.app-name }}-${{ inputs.slug }}"
|
--resource-name "${{ steps.derive.outputs.resource-name }}"
|
||||||
|
|
||||||
- name: Stop preview container
|
- name: Stop preview container
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
CONTAINER="${{ inputs.app-name }}-${{ inputs.slug }}"
|
CONTAINER="${{ inputs.app-name }}-${{ steps.derive.outputs.slug }}"
|
||||||
docker stop "$CONTAINER" 2>/dev/null || true
|
docker stop "$CONTAINER" 2>/dev/null || true
|
||||||
docker rm "$CONTAINER" 2>/dev/null || true
|
docker rm "$CONTAINER" 2>/dev/null || true
|
||||||
docker rmi "${{ inputs.app-name }}:${{ inputs.slug }}" 2>/dev/null || true
|
docker rmi "${{ inputs.app-name }}:${{ steps.derive.outputs.slug }}" 2>/dev/null || true
|
||||||
|
|||||||
@@ -5,58 +5,103 @@ inputs:
|
|||||||
app-name:
|
app-name:
|
||||||
required: true
|
required: true
|
||||||
description: Application name (used for image/container naming)
|
description: Application name (used for image/container naming)
|
||||||
tag:
|
branch:
|
||||||
required: true
|
required: true
|
||||||
description: Image/container tag (e.g., "production" or a branch slug)
|
description: Branch name; the repo's default branch deploys as production, everything else as a preview
|
||||||
port:
|
|
||||||
required: true
|
|
||||||
description: Host port to expose
|
|
||||||
internal-port:
|
internal-port:
|
||||||
required: false
|
required: false
|
||||||
default: "3000"
|
default: "80"
|
||||||
description: Port the app listens on inside the container
|
description: Port the app listens on inside the container
|
||||||
environment:
|
|
||||||
required: true
|
|
||||||
description: Environment name ("production" or "preview")
|
|
||||||
subdomain:
|
|
||||||
required: true
|
|
||||||
description: Subdomain for Pangolin resource
|
|
||||||
build-args:
|
build-args:
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
description: Extra docker build args (space-separated KEY=VALUE pairs)
|
description: Extra docker build args (space-separated KEY=VALUE pairs)
|
||||||
|
env-vars:
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
description: |
|
||||||
|
Runtime env vars for the container, one KEY=VALUE per line.
|
||||||
|
Merged on top of /opt/apps/${app-name}/.env.${environment} on the runner;
|
||||||
|
keys defined here win. Use secrets to avoid leaking values into logs.
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
- name: Derive deploy parameters
|
||||||
|
id: derive
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
APP_NAME: ${{ inputs.app-name }}
|
||||||
|
BRANCH: ${{ inputs.branch }}
|
||||||
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
||||||
|
run: |
|
||||||
|
BRANCH="${BRANCH#refs/heads/}"
|
||||||
|
DEFAULT_BRANCH="${DEFAULT_BRANCH:-main}"
|
||||||
|
|
||||||
|
if [[ "$BRANCH" == "$DEFAULT_BRANCH" ]]; then
|
||||||
|
TAG="production"
|
||||||
|
ENVIRONMENT="production"
|
||||||
|
SUBDOMAIN="$APP_NAME"
|
||||||
|
PORT=$(( 10000 + ( $(echo -n "${APP_NAME}-production" | cksum | awk '{print $1}') % 10000 ) ))
|
||||||
|
else
|
||||||
|
SLUG=$(echo "$BRANCH" | tr '/_' '--' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | cut -c1-40)
|
||||||
|
TAG="$SLUG"
|
||||||
|
ENVIRONMENT="preview"
|
||||||
|
SUBDOMAIN="${SLUG}.${APP_NAME}"
|
||||||
|
PORT=$(( 20000 + ( $(echo -n "$SLUG" | cksum | awk '{print $1}') % 10000 ) ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
REPO_SLUG="${GITHUB_REPOSITORY//\//-}"
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "tag=$TAG"
|
||||||
|
echo "environment=$ENVIRONMENT"
|
||||||
|
echo "subdomain=$SUBDOMAIN"
|
||||||
|
echo "port=$PORT"
|
||||||
|
echo "resource-name=${REPO_SLUG}-${TAG}"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
BUILD_ARGS="--build-arg APP_ENV=${{ inputs.environment }}"
|
BUILD_ARGS="--build-arg APP_ENV=${{ steps.derive.outputs.environment }}"
|
||||||
for arg in ${{ inputs.build-args }}; do
|
for arg in ${{ inputs.build-args }}; do
|
||||||
BUILD_ARGS="$BUILD_ARGS --build-arg $arg"
|
BUILD_ARGS="$BUILD_ARGS --build-arg $arg"
|
||||||
done
|
done
|
||||||
docker build \
|
docker build \
|
||||||
$BUILD_ARGS \
|
$BUILD_ARGS \
|
||||||
-t ${{ inputs.app-name }}:${{ inputs.tag }} \
|
-t ${{ inputs.app-name }}:${{ steps.derive.outputs.tag }} \
|
||||||
-f dockerfile .
|
-f dockerfile .
|
||||||
|
|
||||||
|
- name: Write workflow env-vars to file
|
||||||
|
id: env-file
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
ENV_VARS: ${{ inputs.env-vars }}
|
||||||
|
run: |
|
||||||
|
OVERRIDE_FILE=""
|
||||||
|
if [[ -n "$ENV_VARS" ]]; then
|
||||||
|
OVERRIDE_FILE=$(mktemp)
|
||||||
|
printf '%s\n' "$ENV_VARS" > "$OVERRIDE_FILE"
|
||||||
|
fi
|
||||||
|
echo "path=$OVERRIDE_FILE" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Deploy container
|
- name: Deploy container
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
bash ${{ github.action_path }}/deploy.sh \
|
bash ${{ github.action_path }}/deploy.sh \
|
||||||
--name "${{ inputs.app-name }}" \
|
--name "${{ inputs.app-name }}" \
|
||||||
--tag "${{ inputs.tag }}" \
|
--tag "${{ steps.derive.outputs.tag }}" \
|
||||||
--port "${{ inputs.port }}" \
|
--port "${{ steps.derive.outputs.port }}" \
|
||||||
--internal-port "${{ inputs.internal-port }}" \
|
--internal-port "${{ inputs.internal-port }}" \
|
||||||
--env "${{ inputs.environment }}"
|
--env "${{ steps.derive.outputs.environment }}" \
|
||||||
|
--env-override "${{ steps.env-file.outputs.path }}"
|
||||||
|
|
||||||
- name: Register Pangolin resource
|
- name: Register Pangolin resource
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
REPO_SLUG="${GITHUB_REPOSITORY//\//-}"
|
|
||||||
bash ${{ github.action_path }}/pangolin-upsert.sh \
|
bash ${{ github.action_path }}/pangolin-upsert.sh \
|
||||||
--subdomain "${{ inputs.subdomain }}" \
|
--subdomain "${{ steps.derive.outputs.subdomain }}" \
|
||||||
--port "${{ inputs.port }}" \
|
--port "${{ steps.derive.outputs.port }}" \
|
||||||
--resource-name "${REPO_SLUG}-${{ inputs.tag }}" \
|
--resource-name "${{ steps.derive.outputs.resource-name }}" \
|
||||||
--target-ip "$PANGOLIN_TARGET_IP"
|
--target-ip "$PANGOLIN_TARGET_IP"
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ set -euo pipefail
|
|||||||
APP_NAME=""
|
APP_NAME=""
|
||||||
TAG=""
|
TAG=""
|
||||||
PORT=""
|
PORT=""
|
||||||
INTERNAL_PORT="3000"
|
INTERNAL_PORT="80"
|
||||||
ENV=""
|
ENV=""
|
||||||
|
ENV_OVERRIDE=""
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
@@ -14,19 +15,36 @@ case $1 in
|
|||||||
--port) PORT="$2"; shift 2 ;;
|
--port) PORT="$2"; shift 2 ;;
|
||||||
--internal-port) INTERNAL_PORT="$2";shift 2 ;;
|
--internal-port) INTERNAL_PORT="$2";shift 2 ;;
|
||||||
--env) ENV="$2"; shift 2 ;;
|
--env) ENV="$2"; shift 2 ;;
|
||||||
|
--env-override) ENV_OVERRIDE="$2"; shift 2 ;;
|
||||||
*) echo "Unknown arg: $1"; exit 1 ;;
|
*) echo "Unknown arg: $1"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
CONTAINER="${APP_NAME}-${TAG}"
|
CONTAINER="${APP_NAME}-${TAG}"
|
||||||
|
ON_DISK="/opt/apps/${APP_NAME}/.env.${ENV}"
|
||||||
|
|
||||||
echo "→ Deploying container: ${CONTAINER} on port ${PORT}"
|
echo "→ Deploying container: ${CONTAINER} on port ${PORT}"
|
||||||
|
|
||||||
docker stop "${CONTAINER}" 2>/dev/null && docker rm "${CONTAINER}" 2>/dev/null || true
|
docker stop "${CONTAINER}" 2>/dev/null && docker rm "${CONTAINER}" 2>/dev/null || true
|
||||||
|
|
||||||
ENV_FILE_ARG=""
|
ENV_FILE_ARG=""
|
||||||
if [[ -f "/opt/apps/${APP_NAME}/.env.${ENV}" ]]; then
|
HAS_ON_DISK=0
|
||||||
ENV_FILE_ARG="--env-file /opt/apps/${APP_NAME}/.env.${ENV}"
|
HAS_OVERRIDE=0
|
||||||
|
[[ -f "${ON_DISK}" ]] && HAS_ON_DISK=1
|
||||||
|
[[ -n "${ENV_OVERRIDE}" && -f "${ENV_OVERRIDE}" ]] && HAS_OVERRIDE=1
|
||||||
|
|
||||||
|
if (( HAS_ON_DISK == 1 && HAS_OVERRIDE == 0 )); then
|
||||||
|
ENV_FILE_ARG="--env-file ${ON_DISK}"
|
||||||
|
elif (( HAS_OVERRIDE == 1 && HAS_ON_DISK == 0 )); then
|
||||||
|
ENV_FILE_ARG="--env-file ${ENV_OVERRIDE}"
|
||||||
|
elif (( HAS_ON_DISK == 1 && HAS_OVERRIDE == 1 )); then
|
||||||
|
MERGED=$(mktemp)
|
||||||
|
# On-disk first, override second; tac/awk/tac keeps the last occurrence per key.
|
||||||
|
{ cat "${ON_DISK}"; echo; cat "${ENV_OVERRIDE}"; } \
|
||||||
|
| grep -Ev '^[[:space:]]*(#|$)' \
|
||||||
|
| tac | awk -F= '!seen[$1]++' | tac \
|
||||||
|
> "${MERGED}"
|
||||||
|
ENV_FILE_ARG="--env-file ${MERGED}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker run -d \
|
docker run -d \
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: Deploy
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main", "**"]
|
branches: ["**"]
|
||||||
delete:
|
delete:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -14,8 +14,8 @@ env:
|
|||||||
PANGOLIN_TARGET_IP: ${{ secrets.PANGOLIN_TARGET_IP }}
|
PANGOLIN_TARGET_IP: ${{ secrets.PANGOLIN_TARGET_IP }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy-production:
|
deploy:
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -23,43 +23,15 @@ jobs:
|
|||||||
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/deploy@v1
|
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/deploy@v1
|
||||||
with:
|
with:
|
||||||
app-name: ${{ vars.APP_NAME }}
|
app-name: ${{ vars.APP_NAME }}
|
||||||
tag: production
|
|
||||||
port: ${{ vars.PROD_PORT }}
|
|
||||||
internal-port: ${{ vars.INTERNAL_PORT }}
|
|
||||||
environment: production
|
|
||||||
subdomain: ${{ vars.PROD_SUBDOMAIN }}
|
|
||||||
|
|
||||||
deploy-preview:
|
|
||||||
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Compute preview slug
|
|
||||||
id: slug
|
|
||||||
uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/slug@v1
|
|
||||||
with:
|
|
||||||
branch: ${{ github.ref_name }}
|
branch: ${{ github.ref_name }}
|
||||||
|
env-vars: |
|
||||||
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/deploy@v1
|
DATABASE_URL=${{ secrets.DATABASE_URL }}
|
||||||
with:
|
API_KEY=${{ secrets.API_KEY }}
|
||||||
app-name: ${{ vars.APP_NAME }}
|
|
||||||
tag: ${{ steps.slug.outputs.slug }}
|
|
||||||
port: ${{ steps.slug.outputs.port }}
|
|
||||||
internal-port: ${{ vars.INTERNAL_PORT }}
|
|
||||||
environment: preview
|
|
||||||
subdomain: ${{ steps.slug.outputs.slug }}.${{ vars.APP_NAME }}
|
|
||||||
|
|
||||||
cleanup-preview:
|
cleanup-preview:
|
||||||
if: github.event_name == 'delete' && github.event.ref_type == 'branch'
|
if: github.event_name == 'delete' && github.event.ref_type == 'branch'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Compute preview slug
|
|
||||||
id: slug
|
|
||||||
uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/slug@v1
|
|
||||||
with:
|
|
||||||
branch: ${{ github.event.ref }}
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
@@ -67,4 +39,4 @@ jobs:
|
|||||||
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/cleanup@v1
|
- uses: https://git.zyrrus.dev/eighty-six/node-deploy-action/cleanup@v1
|
||||||
with:
|
with:
|
||||||
app-name: ${{ vars.APP_NAME }}
|
app-name: ${{ vars.APP_NAME }}
|
||||||
slug: ${{ steps.slug.outputs.slug }}
|
branch: ${{ github.event.ref }}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
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: |
|
|
||||||
BRANCH="${{ inputs.branch }}"
|
|
||||||
BRANCH="${BRANCH#refs/heads/}"
|
|
||||||
SLUG=$(echo "$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