Skip to content
Merged
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
78 changes: 78 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy Preview

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches-ignore:
- main

permissions:
contents: read
pull-requests: write

defaults:
run:
shell: bash

jobs:
preview:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.154.3
steps:
- name: Install Hugo
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
sudo dpkg -i ${{ runner.temp }}/hugo.deb

- name: Checkout
uses: actions/checkout@v4

- name: Build with Hugo
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
run: |
hugo --minify --baseURL "https://agentevals-dev.github.io/website-preview/"

- name: Deploy to preview repo
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.PREVIEW_DEPLOY_TOKEN }}
external_repository: agentevals-dev/website-preview
publish_branch: gh-pages
publish_dir: ./public

- name: Comment preview URL on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const previewUrl = 'https://agentevals-dev.github.io/website-preview/';
const body = `🔗 **Preview deployed:** ${previewUrl}\n\nUpdated from commit ${context.sha.substring(0, 7)}`;

// Find existing bot comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(c =>
c.user.type === 'Bot' && c.body.includes('Preview deployed')
);

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}
Loading