Skip to content

Commit 212036f

Browse files
sebbycorpsebbycorp
authored andcommitted
Revert "chore: remove failing Deploy Preview workflow"
This reverts commit c0746fa.
1 parent c0746fa commit 212036f

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/preview.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
push:
7+
branches-ignore:
8+
- main
9+
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
preview:
20+
runs-on: ubuntu-latest
21+
env:
22+
HUGO_VERSION: 0.154.3
23+
steps:
24+
- name: Install Hugo
25+
run: |
26+
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
27+
sudo dpkg -i ${{ runner.temp }}/hugo.deb
28+
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Build with Hugo
33+
env:
34+
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
35+
run: |
36+
hugo --minify --baseURL "https://agentevals-dev.github.io/website-preview/"
37+
38+
- name: Deploy to preview repo
39+
uses: peaceiris/actions-gh-pages@v4
40+
with:
41+
personal_token: ${{ secrets.PREVIEW_DEPLOY_TOKEN }}
42+
external_repository: agentevals-dev/website-preview
43+
publish_branch: gh-pages
44+
publish_dir: ./public
45+
46+
- name: Comment preview URL on PR
47+
if: github.event_name == 'pull_request'
48+
uses: actions/github-script@v7
49+
with:
50+
script: |
51+
const previewUrl = 'https://agentevals-dev.github.io/website-preview/';
52+
const body = `🔗 **Preview deployed:** ${previewUrl}\n\nUpdated from commit ${context.sha.substring(0, 7)}`;
53+
54+
// Find existing bot comment
55+
const comments = await github.rest.issues.listComments({
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
issue_number: context.issue.number,
59+
});
60+
const botComment = comments.data.find(c =>
61+
c.user.type === 'Bot' && c.body.includes('Preview deployed')
62+
);
63+
64+
if (botComment) {
65+
await github.rest.issues.updateComment({
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
comment_id: botComment.id,
69+
body: body,
70+
});
71+
} else {
72+
await github.rest.issues.createComment({
73+
owner: context.repo.owner,
74+
repo: context.repo.repo,
75+
issue_number: context.issue.number,
76+
body: body,
77+
});
78+
}

0 commit comments

Comments
 (0)