File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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
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 }}
You can’t perform that action at this time.
0 commit comments