Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Deploy to ephemeral
on:
pull_request:

jobs:
branch-slug:
uses: ./.github/workflows/slugify.yaml
with:
value: ${{ github.head_ref }}

deploy-dev:
if: contains(github.event.pull_request.labels.*.name, 'preview')
runs-on: ubuntu-latest
needs: branch-slug
environment:
name: dev
url: https://${{ needs.branch-slug.outputs.slug }}.chat-dev.huggingface.tech/chat/
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Set GITHUB_SHA_SHORT from PR
if: env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT != null
run: echo "GITHUB_SHA_SHORT=${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" >> $GITHUB_ENV

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
huggingface/chat-ui
tags: |
type=raw,value=dev-${{ env.GITHUB_SHA_SHORT }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and Publish HuggingChat image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-to: type=gha,mode=max,scope=amd64
cache-from: type=gha,scope=amd64
provenance: false
build-args: |
INCLUDE_DB=false
APP_BASE=/chat
PUBLIC_COMMIT_SHA=${{ env.GITHUB_SHA_SHORT }}
72 changes: 72 additions & 0 deletions .github/workflows/slugify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Generate Branch Slug

on:
workflow_call:
inputs:
value:
description: 'Value to slugify'
required: true
type: string
outputs:
slug:
description: 'Slugified value'
value: ${{ jobs.generate-slug.outputs.slug }}

jobs:
generate-slug:
runs-on: ubuntu-latest
outputs:
slug: ${{ steps.slugify.outputs.slug }}

steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Generate slug
id: slugify
run: |
# Create working directory
mkdir -p $HOME/slugify
cd $HOME/slugify

# Create Go script
cat > main.go << 'EOF'
package main

import (
"fmt"
"os"
"github.com/gosimple/slug"
)

func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: slugify <text>")
os.Exit(1)
}

text := os.Args[1]
slugged := slug.Make(text)
fmt.Println(slugged)
}
EOF

# Initialize module and install dependency
go mod init slugify
go mod tidy
go get github.com/gosimple/slug

# Build
go build -o slugify main.go

# Generate slug
VALUE="${{ inputs.value }}"
echo "Input value: $VALUE"

SLUG=$(./slugify "$VALUE")
echo "Generated slug: $SLUG"

# Export
echo "slug=$SLUG" >> $GITHUB_OUTPUT
Loading
Loading