Skip to content

Commit 9cc2de8

Browse files
committed
ephemeral url
1 parent 9349b0e commit 9cc2de8

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/branch-slug.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Branch Slug Generator'
2+
description: 'Generate a slug from branch name using gosimple/slug'
3+
inputs:
4+
branch-name:
5+
description: 'Branch name to slugify'
6+
required: true
7+
outputs:
8+
slug:
9+
description: 'Slugified branch name'
10+
value: ${{ steps.generate.outputs.slug }}
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: '1.21'
19+
20+
- name: Generate slug
21+
id: generate
22+
shell: bash
23+
run: |
24+
cat > /tmp/slugify.go << 'EOF'
25+
package main
26+
27+
import (
28+
"fmt"
29+
"os"
30+
"github.com/gosimple/slug"
31+
)
32+
33+
func main() {
34+
if len(os.Args) < 2 {
35+
fmt.Println("Usage: slugify <text>")
36+
os.Exit(1)
37+
}
38+
39+
text := os.Args[1]
40+
slugged := slug.Make(text)
41+
fmt.Println(slugged)
42+
}
43+
EOF
44+
45+
cd /tmp
46+
go mod init slugify
47+
go get github.com/gosimple/slug
48+
go build -o slugify slugify.go
49+
50+
SLUG=$(/tmp/slugify "${{ inputs.branch-name }}")
51+
echo "slug=$SLUG" >> $GITHUB_OUTPUT
52+
echo "Generated slug: $SLUG"

.github/workflows/deploy-dev.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ jobs:
66
build-and-publish-huggingchat-image:
77
if: contains(github.event.pull_request.labels.*.name, 'preview')
88
runs-on: ubuntu-latest
9+
environment:
10+
name: dev
11+
url: ${{ steps.branch_slug.outputs.slug }}.chat-dev.huggingface.tech
912
steps:
1013
- name: Checkout
1114
uses: actions/checkout@v4
@@ -51,3 +54,9 @@ jobs:
5154
INCLUDE_DB=false
5255
APP_BASE=/chat
5356
PUBLIC_COMMIT_SHA=${{ env.GITHUB_SHA_SHORT }}
57+
58+
- name: Get branch slug
59+
id: branch_slug
60+
uses: ./.github/workflows/branch-slug.yaml
61+
with:
62+
branch-name: ${{ github.head_ref }}

0 commit comments

Comments
 (0)