diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index 40c79953..00000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Preview integration page - -on: - pull_request_target: - paths: - - 'integrations/**' - - 'logos/**' - -jobs: - preview: - runs-on: ubuntu-latest - environment: Preview - permissions: - issues: write - pull-requests: write - steps: - - name: Trigger Vercel preview build - id: deploy - env: - VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }} - HAYSTACK_HOME_REPO_ID: ${{ secrets.HAYSTACK_HOME_REPO_ID }} - INTEGRATIONS_REPO: ${{ github.event.pull_request.head.repo.clone_url }} - INTEGRATIONS_BRANCH: ${{ github.event.pull_request.head.ref }} - run: | - payload=$(jq -n \ - --arg name "haystack-home" \ - --arg project "$VERCEL_PROJECT_ID" \ - --argjson repoId "$HAYSTACK_HOME_REPO_ID" \ - --arg ref "main" \ - --arg integrations_repo "$INTEGRATIONS_REPO" \ - --arg integrations_branch "$INTEGRATIONS_BRANCH" \ - '{ - name: $name, - project: $project, - gitSource: {type: "github", repoId: $repoId, ref: $ref}, - env: {INTEGRATIONS_REPO: $integrations_repo, INTEGRATIONS_BRANCH: $integrations_branch} - }') - RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ - "https://api.vercel.com/v13/deployments?teamId=$VERCEL_TEAM_ID" \ - -H "Authorization: Bearer $VERCEL_TOKEN" \ - -H "Content-Type: application/json" \ - -d "$payload") - http_code=$(echo "$RESPONSE" | tail -1) - body=$(echo "$RESPONSE" | head -n -1) - if [ "$http_code" -ge 400 ]; then - echo "Vercel API error $http_code: $body" - exit 1 - fi - url=$(echo "$body" | jq -er '.url') - echo "url=$url" >> "$GITHUB_OUTPUT" - - - name: Comment preview URL on PR - uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b - with: - script: | - const url = '${{ steps.deploy.outputs.url }}'; - const branch = '${{ github.event.pull_request.head.ref }}'; - const body = [ - '### Preview deployment', - '', - 'Vercel is building the preview. Once ready:', - `**[View integrations on preview site](https://${url}/integrations/)**`, - '', - `*Built from \`${branch}\` @ ${{ github.event.pull_request.head.repo.full_name }}*`, - ].join('\n'); - - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - }); - const existing = comments.find(c => c.body.includes('### Preview deployment')); - if (existing) { - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: existing.id, - body, - }); - } else { - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body, - }); - } diff --git a/preview-build.sh b/preview-build.sh new file mode 100755 index 00000000..646e667f --- /dev/null +++ b/preview-build.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -euo pipefail + +HUGO_VERSION="0.155.2" +wget -q "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" +tar -xzf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" hugo +export PATH="$PWD:$PATH" + +git clone --depth=1 https://github.com/deepset-ai/haystack-home.git _site +cd _site + +cp ../integrations/*.md content/integrations/ +cp -R ../logos/* static/logos/ 2>/dev/null || true + +npm install + +PREVIEW_URL="${VERCEL_URL:-localhost}" +hugo -b "https://${PREVIEW_URL}" diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..1d103172 --- /dev/null +++ b/vercel.json @@ -0,0 +1,4 @@ +{ + "buildCommand": "./preview-build.sh", + "outputDirectory": "_site/public" +}